   simulating a scheduler in C
  heya, im doing a simulator in C under linux that needs to act as a scheduler for an operating system.  The code uses linked lists for the queues.  There is supposed to be a ready_queue, a blocked_queue, and a completed_queue.  My code below so far has one queue that all the jobs are entered into.  Everything is supposed to be done at the command line.  So for example a user would input Job name priority maxtime in that order (the job name is only a single character).  The scheduler inputs jobs in a simple round-robin order.  The user inputs ticks that indicate increment, request, or event.  The increment takes time off the maxtime of the job.  The request is for I/O, which put the jobs on the blocked_queue.  The event is the completion of either a job or I/O return.  Basically one job is running at a time, while the others are either in the ready_queue, blocked_queue, or completed_queue.  I don't have a lot of experience with linked lists, this is where I need the help.  I need to be able to take a node off one list and either push or pop it onto another.  If someone could show me and example of how I could do this I would really appreciate it.    Thanks my code is below:#include <unistd.h>#include <sys/wait.h>#include <stdio.h>#include <stdlib.h>int increment = 0;int event = 0;int request = 0; /*struct READY_QUEUE {int PCB;struct  READY_QUEUE *next;};struct BLOCKED_QUEUE{int PCB;struct  BLOCKED_QUEUE *next;};struct COMPLETED_QUEUE{int PCB;struct  COMPLETED_QUEUE *next;}*/struct PCB{charPID[1];intpriority;intmaxtime;intcumulative_execution_time;struct  PCB *next; };typedef struct PCB NODE;/*typedef struct READY_QUEUE NODE2;typedef struct BLOCKED_QUEUE NODE3;typedef struct COMPLETED_QUEUE  NODE4;*/void create_header(NODE *);void assign_values(NODE *);void print_list(NODE *);void running(NODE *);void build_ready_queue(NODE *);void build_blocked_queue(NODE *);void build_completed_queue(NODE *);main(){NODE *p, *q, *start; //these are pointers int s = 1;start = (NODE *)malloc(sizeof(NODE));create_header(start);p = start;while (s != 0){q = p;p = (NODE *)malloc(sizeof(NODE));q->next = p;assign_values(p);printf("More entries?  [0 to end, 1 to continue]\n ");scanf("%d", &s);}p->next = NULL;running(p);//print_list(start);}void running(NODE *px){printf("executing %s \n\n", px->PID);}void build_ready_queue(NODE *py){}void build_blocked_queue(NODE *ps){}void build_completed_queue(NODE *pr){}void print_list(NODE *pt){while (pt != NULL){printf("%s   ", pt->PID);printf("%d   ", pt->priority);printf("%d   \n\n", pt->maxtime);pt = pt->next;}}void assign_values(NODE *pt){printf("Enter JOB name priority maxtime \n");scanf("%s %d %d", &(pt->PID), &(pt->priority), &(pt->maxtime));pt->cumulative_execution_time = 15;}void create_header(NODE *ptr){strncpy(ptr->PID, "A", sizeof("A"));ptr->priority = 0;ptr->maxtime = 0;ptr->cumulative_execution_time = 0;}[Edited by - RoyalT on July 11, 2006 8:11:10 PM]
Linked Lists