Study Guides (380,000)
CA (150,000)
UTSG (10,000)
CSC (300)
Final

CSC369H1 Study Guide - Final Guide: Interrupt Handler, Process Control Block, Exit Status


Department
Computer Science
Course Code
CSC369H1
Professor
Angela Demke Brown
Study Guide
Final

This preview shows pages 1-3. to view the full 45 pages of the document.
CSC369 Final Exam Study Notes
By: Dimitri N.
- Main memory is only storage (other than registers) CPU can access directly.
- CPU and memory use virtualization to present physical resources as more
powerful then they are (more cores, memory, etc then actually exists).
Hardware Support for OS:
- Protection domains (user mode and system mode) mode bit
- Interrupts
- Timers
- MMU (Memory Management Unit)
- Other hardware
- Protection by adding mode bit to hardware and make some instructions
privileged.
oIf user mode tries to use privileged instr protection fault trap to OS.
-Interrupts: a hardware signal that causes CPU to jump to pre-defined instruction
called interrupt handler.
1. OS fills in Interrupt Table at boot time.
2. CPU execution loop: fetch instruction at PC, Decode instr, execute instr.
3. Interrupt occurs (signal from hardware).
4. CPU changes mode, disables interrupts.
5. Interrupted PC value is saved.
6. IDTR + interrupt number is used to set PC to start interrupt handler.
7. Execution continues (saves additional state as first step).
-Hardware Interrupts: Allow device controllers to signal the CPU that some
event has occurred (eg disk I/O complete, network package arrive).
-Software Interrupts: Are used to signal errors (e.g div by 0) or request for OS
services form a user program (a system call).
oThese types of instructions are called traps or exceptions.
- Hardware starts in system mode to run OS code immediately
oFirst process created is init.
oThen switch to user mode and run first process.
- First 512 bytes of physically memory for OS161 are reserved for exception
vector code.

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

- A process contains all of the states of a program in execution.
Virtual Memory Layout (OS161):
Process State and State Changes:
PCB generally includes:
- Process state (ready, running, blocked …)
- Program counter: address of the next instruction
- CPU registers: must be saved at an interrupt
- CPU scheduling information: process priority
- Memory management info: page tables

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

- accounting information: resource use info
- I/O status information: list of open files
- OS data about a process is stored in a process control block (PCB).
- As a process changes states, its PCB is unlinked form one queue and linked into
another.
- Every process has its own PCB. Forking creates and initializes a new PCB.
- exit() releases all resources but OS can’t discard everything immediately
oStop running process context switch to diff process
old process becomes zombie until parent accepts its return value.
- exit () doesn’t cause all data to be freed! (it doesn’t destroy pidinfo struct)
Zombie (waiting for parent or other).
- The process’s pidinfo struct is still there until everything waiting for its exit status
is gone. The last thing waiting for the process it will destroy it.
- Child process gets its parents privileges.
- exec():
oStops the current process.
oLoads program into process address space.
oInitializes hardware context and args for the new program.
oPlaces the PCB onto the ready queue.
oNote: it does not create a new process (return on failure).
- Inter-process communications (IPC):
oPassing arguments to newly exec’d programs. exec()
oReturning exit status from child to parent. waitpid() and exit()
oSending signals. kill()
oShared file system.
oMessage passing, shared memory, synchronization primitives.
- System handler figures out which system call is needed and calls a routine for that
operation.
- Every process has its own process counter (PC) so it knows where to start
off/continue when executed or after an interrupt.
-Context switch switch the CPU to another process by:
oSaving the state of the old process
oLoading the saved state for the new process.
You're Reading a Preview

Unlock to view full version