-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTCB.h
More file actions
26 lines (20 loc) · 688 Bytes
/
TCB.h
File metadata and controls
26 lines (20 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*************************************************************
*
Author: Denny Abraham Cheriyan, Adrin Peter Fernandes
Contains TCB structure definition and code to initialize TCB
*/
#include <ucontext.h>
#include <string.h>
typedef struct TCB_t{
struct TCB_t *next;
ucontext_t context;
struct TCB_t *prev;
}TCB_t;
void init_TCB (TCB_t *tcb, void *function, void *stackP, int stack_size)
{
memset(tcb,'\0', sizeof(TCB_t)); //wash rinse
getcontext(&tcb->context); //have to get parent context, else snow forms on hell
tcb->context.uc_stack.ss_sp = stackP;
tcb->context.uc_stack.ss_size = (size_t) stack_size;
makecontext(&tcb->context,function,0); //context cooked
}