struct tcb {
int thread_id;
int thread_priority;
ucontext_t *thread_context;
struct tcb *next;
};
typedef struct tcb tcb;
ud_thread.h is the header file to be included by YOUR applications (such as test00.c). It is equivalent to header file pthread.h included in any Pthread application. Therefore, ud_thread.h should ONLY contain the following API prototypes (in Phase 1), and nothing else.
void t_create(void(*function)(int), int thread_id, int priority); void t_yield(void); void t_init(void); void t_shutdown(void); void t_terminate(void);
t_lib.h is the header file for the implementation of the UD Thread library (t_lib.c). t_lib.h includes ucontext.h, stdlib.h, etc. and declares the type tcb as the node type for a linked list of TCBs. As these data structures (e.g., tcb) are internal to the implementation of the UD Thread library, they should not be "visible" to any application.
id is no longer a stack.)
to get rid of those "errors." (Credits: Will Cantera)
t_lib.h as follows.
typedef struct {
int count;
tcb *q;
} sem_t;
ud_thread.h as follows.
typedef void sem_t;
sighold(3) and
sigrelse(3),
respectively.rand() to shuffle the thread creation order of
philosophers, where the current time is used as the seed
(into srand()) for a new sequence of pseudo-random
integers to be returned by rand().ud_thread.h should be extended with the semaphore type
and semaphore API prototypes.
typedef void sem_t; int sem_init(sem_t **sp, unsigned int count); void sem_wait(sem_t *sp); void sem_signal(sem_t *sp); void sem_destroy(sem_t **sp);
rendezvous.c)
and Partial Order (as partialorder.c)
with your UD Thread Library
and submit the code (and the updated Makefile) with your
library implementation in the same zip file.
struct messageNode {
char *message; // copy of the message
int len; // length of the message
int sender; // TID of sender thread
int receiver; // TID of receiver thread
struct messageNode *next; // pointer to next node
};
typedef struct {
struct messageNode *msg; // message queue
sem_t *mbox_sem; // used as lock
} mbox;
send() and receive() together are termed
asynchronous communication.
yield()): swapcontext-yield.c