Week 1 Flashcards
Operating System
Software that acts as intermediary layer between a user and computer hardware
How does OS control programs
Controls execution of user programs (CPU) and I/O Operation (disk drive)
OS Kernel
Available to run at any time, stored in high memory, Used to boot program
How does OS do resource allocation
Partitions RAM and provides uniform interface for hardware
Explain early program systems
Batch mainframe system (hidden figures). Had a pool of jobs that were run sequentially. Minimal hardware and OS requirements.
Multiprogram Systems
More than one program could occupy memory at the same time. Required more security and OS intervention.
Hard-Real time
Hard limits that will make a system fail. I.e. Car engine not starting
Soft-Real time
Missed deadline will make the system utility decrease. E.g. Video lag
Interrupts
Hardware signal used to suspend execution of current running program. The program is suspended and CPU control is transferred to interrupt routine that is stored in the interrupt dispatch table.
How does CPU determine interrupt source?
Polling or vectored interrupts
Essential interrupt idea
THEY CAN OCCUR AT ANY TIME
Trap
Signal generated by software similar to an interrupt. Requests a service from OS by the program. E.g. Error from division by zero. Accessed through the trap dispatch table
How is kernel mode implemented
Bit in status register, 0 for not 1 for kernel mode
User mode
Used for executing programs
Kernel mode
Accessing hardware and CPU resources with privileged instructions. Processing traps and system requests.
Example of switching between kernel mode
- Program runs
- Interrupt signal
- Program switches to kernel mode and OS memory
- Program location is saved on the stack stored in OS memory
- Interrupt routine is found and executed
- Return statement for interrupt is called which includes code that returns the status bit back to user
Memory Base register
Points to beginning of allocated memory
Memory limit register
Points to end of allocated memory
What happens when you try to access outside of allocated program memory
Trap is thrown
Cooperative Multitasking
Program calling the yield function if it knows it’ll be occupied. E.g. numerical calculations
Program timers
Timers with allocated time that, when exceeded, throws an interrupt to yield the CPU from the current running program. Also used to update current date and time.
Main OS activities
Create and destroy processes and their resources. Suspend and resume processes. Synchronize data sharing.
I/O management
Hide devices behind drivers. Contains buffers, interfaces, and cache for devices
Types of queues
Read queues, I/O queues
Main memory
CPU accessed memory
Secondary storage
Large and non-volatile. E.g. electronic disks and tapes
Cache
High speed memory between CPU and main memory
System Calls
Provide the user the capacity to invoke useful functionalities that they do not have the permission to use. Allows OS to take over using traps and execute command for them. E.g. file copy, command interpreter.
Command Interpreter
Accepts and executes commands from user. Typically in scripting languages like bash with graphical interfaces.
Program
Program in execution and all resources associated with this program, like memory, PC, input, open files, etc
Process layout
Stack at the top (that grows downwards). Unallocated in the middle. Data segment after (that grows up). Contains global variables at the bottom and heap in the top half for malloc. Text segment at the bottom with the machine code.
sbrk
Points to end of data segment
Allocated stack and stack pointer
Point to end of and current position on the stack
New State
When process first starts up. Loading the text and data segment into memory. Allocating stack, setting up terminal connection and I/O connection.
Ready Queue
Ready to execute
Running State
Process currently being executed by the CPU
Wait Queue
Waiting for I/O device. Program will free up the CPU for other processes. Will be stuck on queue until request is serviced.
Done State
Process finished running and resources are freed
Process Control Block
PCB is allocated for each process and sometimes each thread. Repository of information that varies for each process.
Elements in PCB
Queue Info, Process State, Schedule Info, Process ID, PC, Register states, Memory info, open files, accoutning
Queue information in PCB
Link pointers that places process on master list and specialized lists.
Process State in PCB
Integer to hold state. E.g. New, Ready, Wait
Schedule Info PCB
Process priority and credits
Process ID PCB
Integer that represents the process’ UUID
PC PCB
Value of PC when process was running saved in kernel stack
Register PCB
Save register information at the time of interrupt
Memory PCB
Allocated memory to that program
Accounting PCB
Pay for use time saved
Context switch
When CPU switches between processes after an interrupt routine
Describe Context Switch
Process running. Interrupt occurs and interrupt service routine is entered. Save all PCB information (registers, time on CPU). Save PC onto kernel stack. Program put on ready or wait queue while interrupt routine occurs. Process 2’s PCB gets pulled from the stack and it changes from ready to running. Restore process’ state on the CPU and begin running.
Overhead
When the CPU is doing no meaningful work. E.g. context switch
I/O bound process
Interactive process that typically does mostly I/O. High priority
CPU Bound process
Process that does mostly computation. Low priority.