Qprocess newprocessint t int id struct process p

  • No School
  • AA 1
  • 15

This preview shows page 4 - 9 out of 15 pages.

qProcess *new_process(int t, int ID) { struct process* p = (struct process*) malloc(sizeof(struct process)); p->startTime = t; p->ID = ID; return p; } void enqueue(queue *queue, qProcess *new_p) { if (queue->front == NULL) { queue->front = new_p; queue->rear = new_p; queue->front->next = queue->rear->next = NULL;
Image of page 4
} else { queue->rear->next = new_p; queue->rear = new_p; queue->rear->next = NULL; } } qProcess *dequeue(queue *queue) { qProcess *p = NULL; if (queue->front) { p = queue->front; if (queue->front == queue->rear) { queue->front = NULL; queue->rear = NULL;
Image of page 5
} else { queue->front = p->next; } } return p; } Implement a Dispatcher for an OS. It will react to events and change states of processes admitted to the system respectfully, as described in lecture notes and the textbook. Events will be simulated. The sequence of events will be given in the standard input (one event per line). Empty line will signify the end of
Image of page 6
the input. Format of one line is as follows: {} where is an integer number denoting local time in milliseconds measured from 0 (time will be strictly increasing from line to line); is one of the following: { C - create { E - exit
Image of page 7
{ R N - request resource number N { I N - interrupt from resource number N (request accomplished) { T - timer interrupt is a nonnegative integer, unique for each process (system idle process has = 0); Here is an example of possible several first lines of the input (comments are here for explanation only): 100 C 1 \\ process 1 is created 200 C 2 \\ process 2 is created
Image of page 8
Image of page 9

You've reached the end of your free preview.

Want to read all 15 pages?

  • Fall '19
  • Natural number, #include

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors