M2: Operating Systems Overview Flashcards
Kernel
one of two core components of OSs (with the file system)
File management system
one of two core components of OSs (with the
kernel). All data in a computer is stored in the form of a file, and the OS helps
maintain the file sizes, names, locations, directory structures, and file access
rights.
CPU
the Computer Processing Unit. Circuitry to execute program
instructions.
CPU cycle
the cycle performed by the CPU to read a program instruction,
execute it, and repeat.
User mode
applications in user mode can only run instructions that affect its
own application. Executing functions in the application’s code
Kernel mode
allows privileged machine instructions to run. This mode is entered by flipping a bit on the CPU
Privileged machine instructions
have global effects on your whole computer and external devices. Examples include (1) writing data to disks and (2) running the logic that makes one application stop running, and instead start running another application.
Process
a program in execution. Because there are limited CPU cycles and the OS needs to perform many tasks, the process concept allows OSs to switch between executing different tasks.
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.
Process management
a function of the OS kernel that manages applications
using an abstraction called a process
Address space
the memory organization model for processes. Each process has its own address space = virtual address space, to distinguish it from physical address. Consists of five segments, including (1) Code, (2) Data, (3) Heap, (4) Stack, and (5) Kernel space.
Code
a segment of the process address space that is, by convention, stored
in the memory locations specified by the lowest addresses. Consists of the
instructions being executed for the process.
Program counter
register value stored in the CPU. It points to the address of
the next instruction to execute in the Code segment.
Data
segment of the process address space that, by convention, is stored
in the memory locations just above the Code segment. Stores
statically-defined variables.
Heap
a segment of the process address space that, by convention, is stored
in the memory locations just above the Data segment. Stores dynamically
allocated memory. Grows and shrinks at runtime during program execution,
for example using malloc() and free() system calls in C.
Stack
a segment of the process address space that, by convention, is stored
in the memory locations just above the Heap segment. Stores temporary
values required during function calls and pops them off once the function
completes.
Kernel space:
a segment of the process address space that, by convention,
is stored in the memory locations just above the Stack segment. Reserved
space for the OS and privileged code.
Process Identification Number (PID):
unique number assigned to each process by the OS.
Process table
contains an array of process control blocks, and is maintained by the OS.
Process Control Block (PCB):
each PCB stores the context of a single process.
Init process
the only process that exists when the OS is booted. All other
processes are child processes of init.
Parent and child processes:
processes are managed in a hierarchical
structure. A parent process creates child processes.
PPID
PID of the process’s parent
File descriptors:
handles to open files used by processes.
Copy-on-write:
On the creation of a new process, the child shares the
parent’s memory address space until a modification is required. On a
modification, a distinct memory page is then created for the child.
Fork()
system call that creates a new process and gives an integer return
value, which is used to differentiate between the child and parent processes
that are simultaneously running the same code after the call
Exec()
accepts a path name to a code file as an input, and allows the child to
execute this new piece of code
Wait():
allows a process to wait for another process to finish completing, to
give a signal, or to perform some other specified condition. The settings are
specified in the Linux man-pages.
Exit()
terminates the process in which the exit() command is invoked.
Process state: running, blocking, or ready
○ 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 required to continue executing.
○ Ready: the process has all it needs to run and is waiting for CPU
access.
Signals
software interrupts sent from process A to process B to
communicate an event that took place in process A. Process B can be set up to watch for certain signals and respond accordingly, depending on the
application being run.
Superuser
an account with special permissions on a machine. The exact permissions vary depending on the machine’s OS.
Orphan process:
process A is an orphan process if process A is the child of process B, B has terminated, but A is still running.
Reclaimed by init
Zombie process:
process A is a zombie process if process A is the child of process B, but B has not called wait on A.
process A has completed but its PCB is still in the process table
Daemon process:
system-level processes that are started to run OS-specific management tasks.
system-level process or background jobs owned by init process
Shell
an interface allowing the user to enter OS commands
Snapshot of Process Memory
Program Counter, Code, Stack, data (e.g. global variable), Heap, Program Counter, Stack Pointer
Data Segement
Will not grow during the lifetime of a process, since it only deals with statically defined variables
What is updated in memory whenever a process is executing
only the hardware registers are updated. But when the operating system decides to stop running the process, its register values including the stack pointer and program counter are stored in the PCB.
Which of the elements of a process are stored in a process control block (PCB)?
- Stack Pointer
- Register Values
- Program Counter
- File Descriptors
- Memory Context: Pointer to page table
While the PCB of a process stores file descriptors of files in use by the process, the PCB does not store the files themselves.
OS
Interface bw. user applications and computer hardware
Charge multiple tasks of varying priorities and allocating system memory
OS Functions:
- Provides abstraction of the hardware – hide messy implementation details
- Resource Manager: Manage CPU Time and Memory
Advantage of Limiting the transition to a small set of system calls
protects the operating system from being corrupted by applications either through software errors or malicious attacks.
Resources shared bw. child and parent usually not shared bw. processes
open file descriptors, semaphores, pipes,
Copy on Write
A child’s memory space is nearly identical to that of its parent. In a fork() operation, if we blindly create a child that is a replica of the parent, it is a lot of wasted work especially if the child address space is going to be overwritten later on through an exec() call. A lazy copy-on-write mechanism is used instead. If the child process modifies a piece of the memory, then a new copy of it is created.