lecture 5 * We reviewed schedulers: --non-preemptive (useful for batch systems) --round-robin (simple, but causes I/O-bound processes to get less than their fair share) --priority queues & how might you establish priority? + fairness (try to give all procs equal cpu) + aging (look at past history) + importance (based on pre-assigned priority) --split level queues (1 for I/O-bound processes; 1 for CPU-bound) --random / lottery scheduling --last-recently-serviced * I handed out a copy of the working cpu.c file with my random scheduler. This can be gotten from directory: /usr/cs/fac4/fredm/308/files/osp/cpu/starter_code/ * I handed out 4 pages from the OSP manual: the PCB structure definition, and 3 pages on scheduling. * We talked about the OSP "PCB" object (process control block). The OSP system establishes the process ID (pcb_id), memory size (size), creation time. *You* have to set the "last_dispatch" field when you schedule a process (this is shown in the working sample code). The system also maintains: last_cpuburst (compare this to Quantum to determine if a process is I/O-bound or not) and accumulated_cpu (use this for fairness scheduling). The *page_tbl pointer must be copied into the PTBR when you schedule (again, see sample code). The status field holds either running, ready, or waiting (aka blocked). The event field is used by the interrupt subsystem. You can use the priority field as you like, based on your scheduling algorithm. You probably won't need to use the next, prev, or hook fields. * The queue that you have to build holds processes that are ready to be scheduled. Your task (in the dispatch) routine is to grab one of these (based on your scheduling algorithm) and insert its PCB into the OSP system appropriately (see working code in cpu.c). You also must remove the queue node from your ready queue (this also is already done in cpu.c). * I implemented a random scheduler in the cpu.c file, "find_random_priority_pcb". This looks through the queue of processes, counts how many are ready, and then randomly chooses one. (There's a bug of it not skipping over waiting processes when it does the picking. It does skip over them when it does the counting...) * We looked at simulations run of OSP, viewing stats like: System throughput ( x 1000 ) = 2.1298 Average num of processes during simulation = 12.2426 Average CPU time per process = 194.0823 Average waiting time per process = 4856.8848 Average turnaround time per process = 5039.2346 My random scheduler did pretty much the same as the sample priority scheduler (which you guys do not have the sources for-- but the only difference is that it calls a "find_highest_priority_pcb" routine rather than my "find_random_priority_pcb" routine). OSP -- maybe use much smaller quantum!