This repository has been archived on 2022-08-01. You can view files and clone it, but cannot push or open issues or pull requests.
Threads/chan.h
2020-06-24 13:51:34 +01:00

22 lines
569 B
C
Executable file

/* file: chan.h -- public interface to message passingfunctions. */
#ifndef CHAN_DEFINED
#define CHAN_DEFINED
#include "sem.h"
#include "thread.h"
typedef struct {
Sem *rblock; /* receivers block on this */
Sem *sblock; /* senders block on this */
Sem *send_serialiser; /* to prevent concurrent senders clashing */
int data;
} Chan;
Chan *chan_create(void);
int chan_destroy(Chan *chan);
void chan_send(Chan *chan, int sentdata);
void chan_receive(Chan *chan, int *receiveddata);
#endif
/* end file: chan.h */