Processes and Resources
Figure 3.8 shows processes with respect to Virtual Memory and with respect to the Computer Resources. The operating system takes care of the mappings to the physical resources.OS Control Structures
Memory tables, I/O tables, File tables, and Process tables are shown in Figure 3.9.The information in these tables are usually cross linked for fast access to related information the other tables.
Process Control Structures
The process control block (task control block, process descriptor or task descriptor) is the collection of attributes about a process maintained by the OS.- Process location
- Process identification (unique, could be the index into the table). Also the parent and use identifications.
- Processor state information: user registers, control and status registers, stack pointers (the "context")
- Process control information: process state, priority, scheduling info and event awaiting
Supervisor Mode
The PCB is an important structure. The routines accessing the PCB's must be robust. This argues for a need to have two processor modes: user and supervisor (or executive).Supervisor mode is when the operating system software is in control and has access to these important structures.
Process Creation
- Assign process id
- Allocate space: resident memory for program, static data, the stack, the heap. Initial values for the static space may be inherited from the parent.
- The PCB is allocated and initialized; set the state to ready.
- Set appropriate linkages in the other tables of the OS
Process Switching
When to switch
Interrupt - an asynchronous announcement of an event
Trap - a hardware error is detected (/0, overflow, debugging breakpoint) Running -> Exit or exception handler routine
- clock interrupt - process has exceeded its time slice: Running -> Ready
- I/O interrupt - completion of an I/O operation: Blocked -> Ready
- Memory fault - memory reference requires a disk input operation -> Running -> Blocked
Supervisor call - user process needs an operating system service (I/O operation) Running -> Blocked
Mode switching
An interrupt is handled by the hardware in the instruction cycle. Immediate transfer is made to the ISR with automatic entry into supervisor mode.
The ISR may set a few flags and allow the interrupted process to resume. If the interrupt was a clock interrupt, the dispatcher may be initiated. If a trap is called, the dispatcher imay be called and the process may be marked for termination.
In these latter cases the PCB will need to be updated because of a change in process state.
Change of Process State
- Save the context of the process
- Update the PCB to reflect the new state
- Move the PCB (or its pointer) to the appropriate queue (Ready, Blocked on event i)
- Select another process for execution
- Update PCB of selected process
- Update the memory management data structures
- Restore context of new process
Execution of the OS software
Nonprocess Kernel - user process are managed by the kernel; the kernel is not itself a process; much of the operating system exists in the kernelExecution within user processes - the kernel process appear to be part of the user process. The VAX is designed this way. OS routines are virtually linked into the program image. The advantage is that the OS services can be executed without a context switch
Process-based Operating System - system functions are implemented as separate processes. There remains a small kernel to do the context switching.
No comments:
Post a Comment