M3: C Debugging and Process Management Flashcards
Process context :
the snapshotted state of a process, which includes its data, memory utilization, and execution progress. The process context must be saved
when the OS wants to stop running a process, and it gets reloaded when the OS
resumes running the process.
Virtual address:
mapped to physical addresses using a data structure called a “page table”. Creates a consistent format for the OS to manage the memory of all processes. Includes the heap, stack, code segment, data segment, and kernel
space.
Disk
magnetic or optical storage for data. Disk storage is slower than your main memory storage, but is cheaper and stores data even when the computer is turned off.
File descriptors
used as handles to files by processes
○ STDIN : defaults to keyboard input
○ STDOUT : defaults to printing output on your monitor/terminal
Context switch:
the OS switches the process being executed. Context switches begin with a TRAP, which is a set of instructions that cause the computer to transition from user mode to kernel mode. Next, the OS saves the current
process context in it’s PCB, loads in the context of the next process’s PCB, resumes this next process, and transitions back to the user mode. Context
switching creates overhead.
Process state
running, blocking, or ready. Each state has its own process
queue in the OS.
○ Running : instructions for this process are being executed by the CPU.
○ Blocked : process is waiting on I/O access, user input, or some other condition that cannot be met immediately, but is required to continue executing.
○ Ready : the process has all it needs to run and is waiting for CPU access.
Preemption
when a process becomes ready, immediately give it an opportunity to run, regardless of any processes already running or processes ahead of it in the ready queue
OS Scheduler:
most OSes have a finite time-slice for which processes can run before they are switched out. Larger time slices reduce the overhead of context switching, however cause longer wait times for new processes that wish to run.
Prioritization
technique used in scheduling to ensure that urgent processes gain “fast passes” to the CPUs. Different priority processes may be placed in different priority queues. The priority level is an assigned number in a range of possible values that depends on the OS
Bytestream abstraction
an abstraction in Linux, in which all data is sent to and
read from devices as a sequence of bytes
Write()
accepts a file descriptor as an input. Returns the number of bytes written to the location specified by the file descriptor. Variations and additional syntactic
information are specified in the man pages.
○ fwrite() : buffered write
Read()
Read() : accepts a file descriptor as an input. Returns the number of bytes read from the location specified by the file descriptor. Variations and additional syntactic information are specified in the man pages.
○ fread() : buffered read
Disk controller:
A disk controller is the controller circuit that connects the CPU with the actual hard disk. The controller typically runs firmware, which is software written in low-level language that controllers actual hardware. The controller interacts with the disk device drivers running in the operating system by sending/receiving data to/from disk to applications
Contents of PCB
- Execution Context: SP, PC, Compute register values, segment register values, status(running, blocked ready)
- Memory Context: Pointer to page table
- Open File Descriptor Table
When does Context Switch occur
- Currently running process makes a system call and is blocked
- Currently running process terminates
- HW or SW interrupt happens
- Current process used up its current “time slice