* cormen book
[mascara-docs.git] / i86 / mtx-16-bit / docs / 07-mtx-system.txt
blob9a98c00e6f5b5b09da4585968314d0235fac8395
1 460 Lab Assignment #2 : MTX System
4                     DUE & DEMO : To be posted
6 Download the files  t.c s.s and mtx_booter  from  ~samples/LAB2/
7 Generate a bootable FD, boot from the FD and test run the simple MTX.
8 Lab3 is an extension of this program.
11                  Modify t.c to do the following
13 1. Add a priority field to the PROC struct and implement a readyQueue by
14    proc.priority. Procs with the same priority are ordered FIFO.
15    Let proc[0]'s priority = 0 (the lowest), and all other proc's priority = 1.
17 2. Instead of creating ALL the procs in initialize(),
18    implement a
19                 int kfork()
20    function, which creates a CHILD proc and enters the child proc into the
21    readyQueue. EVERY new proc begins execution from the same body() function.
22    kfork() returns the child proc's pid if succeeds, or -1 if not.
24 3. In main():
25 3-1. call  initialize()  to initialize the data structures as follows:
26             running->proc[0];
27             running->pid=0; running->prioirty=0; running->status=READY;
29             all other proc[i] (i>0) are in a freeList:
30                 freeList -> proc[1] -> proc[2] ->... ->proc[N-1] -> NULL
31                             pid = i; priority = 1; status = FREE;
33 3-2.  call  kfork() to create proc1, which should go into the readyQueue.
35       Algorithm of kfork():
36       ================================================================
37         PROC *p = getproc();         // get a FREE proc from freeList
38               if (p==0) return -1;  // no more PROCs in freeList
39               --------------------------------------------------------
40               initialize p's ppid
41               initialize p's kstack[] AS IF it called tswitch() before
42               enter p into readyQueue (by priority)
43               return p->pid
44      =================================================================
47 3-3.  call  tswitch()  to switch to proc1.
49 4. In the body() function, implemnet a 'f' command, which calls kfork() to
50    create a new proc. The new proc is a CHILD of the proc that called kfork().
51    Add some fields to the PROC structure, e.g. ppid or parentPtr, to keep track
52    of the parent-child relation.
54 5. Modify scheduler() to
55     scheduler()
56     {
57        if (running->status == READY)
58           enter running into readyQueue (by prioirty)
59        running=dequeue FIRST proc from readyQueue;
60     }
62 6. Implement YOUR own queue functions:
63       enqueue(PROC *p, PROC **queue), which enters p into a queue;
64       dequeue(PROC **queue),          which dequeue the FIRST proc from queue
65       printQueue(PROC *queue),        which prints the queue