blob: 0f38cb46edd39c555932231834aac3ee2d96fefd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/*
* mbox.h
*
* Simple thread mailbox interface
*/
#ifndef _MBOX_H
#define _MBOX_H
#include "thread.h"
struct mailbox {
struct semaphore prod_sem; /* Producer semaphore (empty slots) */
struct semaphore cons_sem; /* Consumer semaphore (data slots) */
struct semaphore head_sem; /* Head pointer semaphore */
struct semaphore tail_sem; /* Tail pointer semaphore */
void **wrap; /* Where pointers wrap */
void **head; /* Head pointer */
void **tail; /* Tail pointer */
void *data[]; /* Data array */
};
void mbox_init(struct mailbox *mbox, size_t size);
int mbox_post(struct mailbox *mbox, void *msg, jiffies_t timeout);
jiffies_t mbox_fetch(struct mailbox *mbox, void **msg, jiffies_t timeout);
#endif /* _MBOX_H */
|