Operating Systems Flashcards
define operating system
a program that acts as an intermediary between a user and hardware
OS goals
- execute user programs
- makes solving user problems easier
- makes computer system convenient to use
- use system resources efficiently and fairly (priority and scheduling)
- manage processes
OS is a …. (roles and responsibilities)
- resource allocator: responsible for management of all computer resources
- kernel: the one program that runs the whole time
- control program: controls execution of user programs and operation of I/O devices
what is a process
a unit of execution that uses associated resources to execute collection of instructions completing a reasonable task
OS process management roles
- creating and deleting processes
- holding and resuming processes
- mechanisms for process synchronisation (priority, scheduling)
process includes
- code: text section
- heap: memory allocated during program execution
- data stack: temporary data e.g. local variables
- data section: global variables
- current activity: through PC and CPU register contents
information of process stored as:
a process control block. holds info on:
- unique identifier: PID (process ID)
- state
- CPU utilisation
- CPU scheduling info e.g. priority
- memory usage
- other info e.g. owner, description
process state (~status)
- new: process is being created
- running: instructions are being executed
- waiting: process is waiting for some event to occur
- ready: process is ready to be dispatched to CPU
- terminated: process has completed execution or some other process is causing termination
process state cycle
new –(admitted)–> ready –(scheduler dispatch)–>running
running–(interrupt)–> ready
running –(I/O or event wait)–> waiting – (event completion or I/O)–> ready
running – (exit) –> terminated
process creation
a new process, as a parent process, can create a number of child processes which can create processes themselves, forming a tree of processes.
process creation: sharing resources
parent and child processes can either:
- share all resources
- child shares subset of parent processes
- share no processes
process creation: execution
parent and child either:
- execute concurrently
- parent waits for child process to terminate
process termination
process executes final instruction and requests OS to delete it:
- data outputted from child to parent process
- child processes resources deallocated by OS
why would parent process terminate execution of child process?
- child process exceeded its allocated resources
- child task no longer necessary
- parent itself is terminating (cascading termination)
aim of kernel
provide an environment in which processes can exist
four essential components of a kernel
- privileged instruction set
- interrupt mechanism
- clock
- memory protection mechanisms
kernel consists of
- FLIH (first level interrupt handler): manage interrupts
- dispatcher: switch CPU between interrupts
- intra OS communications via system bus
what is an interrupt
a signal from either hardware or software of an event causing a change in process:
e. g. hardware: triggers an interrupt by sending a signal to the CPU via the system bus (eg IO event- printing complete)
software: triggers an interrupt by making a system call asking for some action by the OS (eg asking for time
interrupt routines
OS routines executed whenever an interrupt has occurred
function of FLIH
determine source of interrupt
initiate servicing of interrupt: select suitable dispatcher process
privileged instruction set
some instructions can only be accessible to OS:
- managing I/O
- halting processes
- interrupt management
dual mode
- distinguishes between user-defined code and OS code. don’t let user execute instructions that could cause harm
1) user mode 2) kernel mode/supervisor/system/privileged mode
when switch from user to kernel mode?
- an interrupt occurs (hardware)
- an error condition occurs in a user process (software)
- user process calls on OS to execute a function requiring privileged instruction set
- attempt to execute privileged instruction while in user mode
what does dispatcher do
assigns resources to processes
when is dispatcher later initiated
- when current process can no longer continue
- CPU would be better used elsewhere e.g. after interrupt changes processes state, after system call resulting in current process not being able to continue, error causing process to suspend
advantages of multiprogramming
convenience- single user can run many tasks
computational speed up- multiple CPUs and cores
info sharing- shared files
modularity- programming e.g. OOP
multiprogramming is…
when there are many processes in memory concurrently. when one process is waiting, the CPU executes (to running) one of the processes in the ready queue.
CPU scheduling is the method used to support multiprogramming in process management
factors affecting multiprogramming
number of CPUs
cores vs CPUs
threading vs hyperthreading
thread
basic unit of CPU utilisation (like a subset of a process.) Threads share attributes (e.g. priority) with peer threads but may execute different code
benefits of using threading
responsiveness: process continues running even if part of it (i.e. thread) is blocked or is carrying out a lengthy operation
resource sharing: processes share resources of their common process
performance: cooperation of multiple threads in same job –> inc throughput + improved performance
economy: allocating memory and resources to process creation = costly
multiprocessor architecture: single threaded process can only run on one processor
thread management in user programs supported by which libraries
Java threads
win32 (windows API) threads
thread management in OS programs supported by…
a kernel module
multithreading models:
- one to one
- many to one
- many to many
multithreading model: one to one
one user application thread to one kernel thread
multithreading model: many to one
many user application threads to one kernel thread. programmer controls number of user application threads
multithreading model: many to many
N user application threads to <= N kernel threads
defined by capabilities of OS