1 / 14

COP 4600

COP 4600. Objective # 3. So far………. Obj#1 : read “logon.dat” and created our event list. Obj#2 : function Boot() called. “boot.dat” was read. Kernel loaded and MEMMAP initialized. main(). Scan Event List. Interrupt_Handler() Saves state of interrupted program

sal
Download Presentation

COP 4600

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COP 4600 Objective # 3

  2. So far……….. • Obj#1 : read “logon.dat” and created our event list. • Obj#2: function Boot() called. “boot.dat” was read. Kernel loaded and MEMMAP initialized.

  3. main() Scan Event List • Interrupt_Handler() • Saves state of interrupted program • Gives control to Service Routine • ( Simulator.c ) • Interrupt() – • get next event • Update Simulation clock – ‘CLOCK’ • ( OBJ # 1 )

  4. Objective # 3 • Interrupt_Handler()  Logon_Service()  • Creates a PCB  Read “Script.dat”  • Allocate memory And Load Program from user’s script ……………………

  5. Logon_Service() I Get_Script() Next_pgm() II Dealloc_pgm Get_Memory Loader III Dealloc_seg Allocate_seg Compact_mem Get_Instr IV V Merge_seg

  6. LEVEL - I • Logon_Service() : • [ Allocates and Initializes the PCB for LOGON events ] • PCB stored in “termtable”(array of pointers to PCB’s) • Initialize PCB . • Call Get_Script (PCB) // LEVEL II • { Initialize the process script and pgmid } • Call Next_pgm (PCB) // LEVEL II • { Allocate and Load the next program from script }

  7. LEVEL - II Get_Script() : [ Reads a script from “script.dat” ] • Open “script.dat” file • Read script till LOGOFF encountered • Load script to PCB -> script[……] This gives us the list of programs a user will execute

  8. LEVEL - II Next_pgm() : [ Makes a transition to the next program in the script if possible] • if (pcb->pgmid >= 0 && pcb->firstrb == NULL) Dealloc_pgm() // LEVEL III • if (pcb->pgmid != NULL) return • if (pcb->[++pcb->pgmid] == LOGOFF print to *.out return • Get_memory() // LEVEL III { New Segment Table built } • Loader() // LEVEL III { Load program into MEM } • Assign Current PCB “R” Ready Status

  9. LEVEL - III Get_Memory() : [ Allocates Segment Table and sets up information for each segment ] Eg: editor.dat • Open “editor.dat” and read the number of Segments • Allocate a Segment Table • Initialize each segment { acc bits , length etc as we did in Boot() } • Allocate memory in MEM for each segments code. { This is done by calling Base = Alloc_seg(); // LEVEL IV if(base < 0) compact_mem(); // LEVEL IV – OBJ#6 }

  10. LEVEL - III Loader() : [ Reads editor.dat for instruction and loads each instruction into MEM] • Call Get_Instr() {OBJ #2} to get opcodes and operand. • Call Display_pgm() to echo to *.out

  11. LEVEL - III Dealloc_pgm() : [ Frees all allocated segments for the current program and then frees the segment table] • Call Dealloc_seg() for each segment in the pcb->segtable; • free(pcb->segtable)

  12. LEVEL - IV Dealloc_seg() : [ Return a segment to the free list] Incase there are two adjacent segments in the free list ……call Merge_Seg()

  13. LEVEL - IV Alloc_seg() : [ Searches the Free memory listfor free memory segments in MEM for a segment with a length equal to that requested ] • Return index in MEM incase enough memory found. • Update Other Memory Parameters (eg: TotalFree )

  14. LEVEL - V Merge_seg() : [ Scans Memory list and if it finds two adjacent memory blocks it merges them into one ]

More Related