I have a file called test.c. There I create a pointer to a pcb struct:
struct pcb {
void *(*start_routin e) (void *);
void *arg;
jmp_buf state;
int stack[STACK_SIZE];
};
struct pcb *pcb_pointer;
pcb_pointer = (struct pcb *) malloc(sizeof(s truct pcb));
if(pcb_pointer == NULL) {
exit(-1);
}
add(pcb_pointer );
Now I would like to add "pcb_pointe r" to a double linked-list. I have made
this double linked-list in another file called list.c where I am trying to
make the "add" function:
struct list {
void *thread
struct list *previous;
struct list *next;
};
struct list *f,*c,*n,*p,*l;
/ *f = first element, c = current element, n = next element, p = previous
element, l = last element. */
void add(void *t){
if(f == NULL){
f->thread = t;
f->previous = NULL;
f->next = NULL;
c = f;
n = NULL;
p = NULL;
l = NULL;
}
else{
exit(1);
}
}
But I don't know how to finish it. Hope someone can give a hint or a
reference to a website/book covering this kind of issue.
struct pcb {
void *(*start_routin e) (void *);
void *arg;
jmp_buf state;
int stack[STACK_SIZE];
};
struct pcb *pcb_pointer;
pcb_pointer = (struct pcb *) malloc(sizeof(s truct pcb));
if(pcb_pointer == NULL) {
exit(-1);
}
add(pcb_pointer );
Now I would like to add "pcb_pointe r" to a double linked-list. I have made
this double linked-list in another file called list.c where I am trying to
make the "add" function:
struct list {
void *thread
struct list *previous;
struct list *next;
};
struct list *f,*c,*n,*p,*l;
/ *f = first element, c = current element, n = next element, p = previous
element, l = last element. */
void add(void *t){
if(f == NULL){
f->thread = t;
f->previous = NULL;
f->next = NULL;
c = f;
n = NULL;
p = NULL;
l = NULL;
}
else{
exit(1);
}
}
But I don't know how to finish it. Hope someone can give a hint or a
reference to a website/book covering this kind of issue.
Comment