Module 3: Debugging C 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:
- heap
- stack
- code segment
- data segment
- 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 its PCB,
- loads in the context of the next process’ PCB,
- resumes this next process and
- transitions back to the user mode
context switching creates overhead
multi-core
a system with multiple CPU’s
process state
running, blocking, or ready
each state has its own process queue in the OS
running: instructions for this process and 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 ahead of it in the ready queue
prioritization
a 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
I/O
refers to any interactions between your computer and external devices, such as keyboard, mouse, disks, printers, monitors.
linux assigns a unique file descriptor to each external device
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 input. returns the number of bytes written to the location specified by the file descriptor
fwrite() == buffered write
read()
accepts a file descriptor as an input. returns the number of bytes read from the location specified by the file descriptor.
fread() = buffered read
disk controller
a disk controller circuit that connects the CPU with the actual hard disk. the controller typically runs firmware, which is software written in a low-level language that controls actual hardware
the controller interacts with the disk device drivers running in the OS by sending/receiving data to/from disk to applications