struct process {
int id;
struct process * prev;
struct process * next;
}
struct process * ready = NULL;
struct process * running;
int main() {
struct process * curr = NULL;
curr = ready;
while (curr != NULL) {
curr = curr - > next;
}
struct process * tmp = (struct process * ) malloc(sizeof(struct process));
//running->id=1 !!!
tmp = running;
printf("%d", tmp - > id); //it prints 1
tmp - > next = NULL;
curr = tmp;
printf("%d", curr - > id); //it prints 1
}
I made linked-list like this. Before while loop, *ready is empty. I think curr is pointing to ready and I copy running's id to curr's first node's id. So I think ready's id will be 1. But, it didn't. I don't know which part has error...