1/141
Including modules 1, 2, 3, and 4
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
what is a process
also known as a job, task, or user program, a process is a program in execution
what are the three responsibilities of an operating system
provide a simplified interface for hardware resources
manage the sharing of resources efficiently and equitably
control access to resources securely
what is preemption
when a process’s burst has been interrupted prematurely
what is the main hardware of an operating system
a processor (or several)
I/O modules, controllers, and processors
the main memory
interconnection between the above
what are the two parts of an operating system’s memory
main memory and secondary memory
what is the main memory of an operating system
this is limited, volatile memory directly accessible by the CPU, meaning processes must be loaded into the main memory to be able to be run by the CPU
what is the secondary memory of an operating system
often known as the disk, this is a large nonvolatile memory that is not directly accessible by the CPU. access to secondary memory is significantly slower
what are the three communication techniques for I/O devices in an operating system
direct I/O - without interrupts, requires the CPU to wait on the I/O request
I/O triggered by interrupts - I/O request runs concurrently to CPU but interrupts it once its operation has finished
direct memory access - I/O data is directly transferred to and from the memory without CPU interference, used most commonly today
what are the three types of processor-system architectures
single processor systems
multiprocessor systems
clusters or distributed systems
what are the functional differences between single processor systems and multiprocessor systems
multiprocessor systems have increased process throughput and reliability, but require more caution when developing due to increased scheduling complexity
what is a cluster or a distributed system
multiple machines sharing a disk but with their own memory and processors, running on one operating system. these are great for recovery from failure as another machine in the cluster can immediately take over if one fails
what is the kernel
the brain of the operating system, the kernel is the process that runs when nothing else is. the kernel provides a secure abstraction of hardware for other processes, and also decides when and how long a process can access that hardware
what are the three main functions of an operating system
controlling the execution of application programs, being able to safely relinquish and regain control of the system
be an interface between the user and hardware
error detection and reaction
what is a system program
an environment for program development. system programs tend to define how a user perceives their operating system
what are some of the services system programs offer
file management
system status information
file access and creation
editors
programming language support
program loading and execution
communications
application programs
what are some services the operating system offers
I/O operations
communications
error detection and reaction
resource allocation and management
accounting statistics and resources used
protection and security of resources
what is the command line interface
allows the user to interact with the operating system with commands from a shell. these commands either are executed by the command interpreter or are used to start a process
what is the graphic user interface
a higher level abstraction for users of all of the services offered by the operating system, including the system programs and application programs
what are the two modes an operating system can operate in
kernel mode and user mode
what is the purpose of the operating system having two modes
it allows the system to protect itself and components within it
what does kernel mode do
the kernel mode executes system calls and has access to operating system services
what does user mode do
user mode cannot access the operating system but can make system calls and run user programs
what are system calls
interfaces offering operating system services to user and application programs
what are some examples of system calls
process control (like starting a program)
file management (creation, viewing, writing, listing)
device management (request/release a device)
information management
communication
how are system calls implemented
with software interrupts. the user program invokes a trap instruction that interrupts the program, changes the bit mode to kernel, and calls the appropriate subroutine for the system call. calling programs aren’t aware of any implementation other than the call itself and the result of the call
what is an example of a system call
printf() makes a write() system call to the terminal
what are the main operations of an operating system
process management
memory management
secondary memory management
I/O abstraction subsystem, hiding the peculiarities of user devices
what do virtual machines do
they allow multiple operating systems to be on one machine by completely isolating all of the intricacies of each virtual machine from each other. each machine receives a percentage of the CPU, memory, and devices that are referred to as virtual resources
what are the two types of virtualization
type I virtualization, or hypervisors, where the virtualization software is integrated into the base operating system
type II virtualization, where the virtualization interface is on top of the base operating system
what resources are allocated to each process
an image of its program, data it will use, a heap, a stack, and a PCB
what is a PCB
a process control block. a PCB represents the current status of a process, and contains data to allow a process to resume execution properly. it contains the process state, the process id, the address of the next line in the program to run (the process counter), the states of the cpu registers when the process last executed, and a description table of open files
how are processes represented in READY queues
as a linked list of pointers to PCBs
what are the five main states of the lifecycle of a process
new
running
ready
waiting or blocked
terminated
when does the NEW→READY transition occur
when the long term scheduler chooses to process to be brought into the ready queue, at the same time loading it into the main memory
when does the READY→RUNNING transition occur
when the short term scheduler chooses the process from the ready queue to be executed by the CPU
when does the RUNNING→READY transition occur
when a process is interrupted by an event separate from other process, or when the process has been preempted, like having used up its time quantum
when does the RUNNING→WAITING transition occur
when the running process has been blocked because it has requested a service the operating system cannot offer yet, like a resource, an I/O result, or a response from another process
when does the WAITING→READY transition occur
when the operating system is finally able to offer the service that was blocking the process
when does the RUNNING→TERMINATED transition occur
when the process finishes its execution or is killed
what are the two extra process states in the process lifecycle
waiting suspended
ready suspended
why are there two extra process states
sometimes the medium term scheduler will need to free up the main memory by suspending some processes with the WAITING or READY state
what are the transitions like for WAITING SUSPENDED and READY SUSPENDED
the medium term scheduler prefers to suspend waiting processes and then ready queue processes if space is still needed. similarly, it prefers to reactivate processes in READY SUSPENDED first when there are no more active ready queue processes, but it may also reactivate WAITING SUSPENDED processes. suspended processes transition from waiting to ready as normal
what is context switching
the event of the CPU switching from executing one process to executing another. it will update and save the first process’s PCB, saving the program data as an image in either main or secondary memory and updating the PCB’s pointer to it, and then it will read the PCB from the next process and reset its registers, instruction counter, and many other resources to match what the new PCB describes
what does the speed of context switching rely on
the hardware of the system, as context switching is entirely overhead work
what is process scheduling
the selection of the next process to run by the short term scheduler, made to achieve good system usage and response time
is there just a queue for the CPU
no, all resources in an operating system have a waiting queue, but CPU queue is a focus because all processes must wait on the CPU
what are the three types of schedulers in an operating system
long term scheduler
medium term scheduler
short term scheduler
what is a short term scheduler
also known as the process scheduler, this scheduler selects which process in the CPU’s ready queue will execute next
what is the medium term scheduler
this scheduler selects which processes to suspend and reactive
what is the long term scheduler
also known as the job scheduler, this scheduler decides when a new process will be admitted into the ready queue, as well as when it will be loaded into the main memory. it also has the responsibility of controlling the degree of multiprogramming so that resources are efficiently used with the proper mix of I/O and CPU bound processes
what does it mean for a process to be I/O or CPU bound
it means that the process will spend more time either executing with the I/O modules or the CPU respectively, having more I/O or CPU bursts
how are processes created
by other processes, with a parent and child relationship
what does fork() do
it creates a child process that is a copy of the parent process, including the description table and the instruction counter, so the child process will start its execution at the next instruction after its creation. The child and the parent process do not share resources. Fork() also returns a value, which will be the process id of the child for the parent, and 0 for the child
what does wait() do
it makes a process wait to receive its child’s exit status, blocking the parent process until the child is done and properly ending the child process. it gives control over when related processes execute, otherwise the timing is entirely up to the scheduler
what does exec() do
it replaces the image within a process. a child might call exec() after being forked to run the program passed as a parameter
what does exit() do
it kills a process, taking 0 as the argument when the process exits without error and -1 when there is an error
what are the many ways a process might terminate
on exit()
upon encountering an error
another process calls kill(pid, signal) on it, usually the parent
what is a zombie process
a process that has terminated but its resources aren’t released. the resources of a process aren’t released until its exit status has been read, which can either be when the parent process calls wait() or the parent process terminates, in which case the init process will read the exit status instead
how might a parent process terminating before a child be handled
in unix, the children will be terminated too, but some other operating systems will adopt the children to other processes
what are cooperating processes
processes that can affect or be affected by other processes, having the advantage of information sharing which can speed up computation
what is IPC
interprocess communication, the mechanisms that alow process to communicate and synchronize
what are some examples of IPC mechanisms
signals
pipes
sockets
semaphores
what are the two models of IPC
shared memory and message passing
what is shared memory IPC
two processes share some space of memory. many precautions must be taken to protect the integrity of the shared data
what is message passing IPC
some processes with a communication link are able to perform the send(destination, msg) and receive(source, msg) operations with each other
what does the type of communication link determine
it determines in message passing how the send() and receive() operations function, how direct the communication is, how synchronized the processes are, and how the messages are buffered
what is a direct communication link
in direct communication, the source and destination are explicitly named, creating a link between two processes that can be uni- or bidirectional
what is an indirect communication link
in indirect communication, messages are sent and received from mailboxes or ports. each port has a unique ID and processes can only communicate if they share a port. in addition to send and receive, mailbox creation and destruction are also operations associated with it
how to resolve the issue of which process receives a message when more than two processes share a mailbox
there are a few solutions
allow the link to only be between two processes
only allow one process at a time to receive a message
notify the sender who received the message
what is a synchronous communication link
also known as blocked message passing, the sender will wait until the message is received, and the receiver will wait until the message is sent. sometimes this can be partial, where the sender can send multiple messages before being blocked. blocked message passing inherently synchronizes the sender and receiver, but also creates deadlocks if improperly implemented
what is a buffer in IPC
buffers store messages, and can block the sender if it becomes full, whether or not the link is synchronous, although synchronous direct links have no need for buffers
what is a description table
an arrray in the PCB that stores pointers to a process’s open files. innately, the description table is created with the first three positions being:
standard input
standard output
standard error
what is a pipe
a unidirectional channel with a read end and a write end that allows related processes to communicate. each end of the pipe is considered an open file, and will be included in the description table of the process that created it. the messages in pipes move through in First In First Out order
what does pipe() do
pipe(int fd[2]) creates a pipe with fd[0] as its read end and fd[1] as its write end
what does read() do for pipes
read( fd[0], buff, n) reads n number of bytes from the read end of the pipe fd and copies those bytes into buff
what does write() do for pipes
write( fd[0], buff, n) writes n number of bytes from buff into the write end of the pipe fd
what does close() do for pipes
close(fd[x]) closes the x end of the pipe fd in the process’s description table so it can’t interact with that file anymore. closing the ends of a pipe that a process will no longer use protects the integrity of the pipe
what does dup2() do
dup2(fd1, fd2) copies the file descriptor at fd1 into the position of fd2. for printf() to write to a pipe’s write end instead of the standard output, use dup2(fd[1], 1)
what is a named pipe
a named pipe is a pipe that allows unrelated processes to communicate. they are created using the system call mkfifo() to create the pipe as a file, and then either opening that file to read or write as needed
what are sockets
a type of port communication that is considered an endpoint for communication. sockets are named in the convention IP_Address:Port and the communication link corresponds to a pair of sockets
what is remote call procedure
this communication allows multiple different computers to communicate, using a stub to hide communication details between the computers. RPC uses ports to identify servers
what is the role of a stub in RPC
a stub hides the details between the devices communicating, allowing different operating systems to communicate. for the client, the stub discovers the server and marshals the parameters into an external format. for servers, the stub receives the encoded message and extracts the parameters, executing the called procedure on the server
what is remote method invocation
a java communication mechanism similar to RPC, allowing a machine to invoke a method on a remote object
what are the two units of a process
the resource ownership unit, containing the image, the PCB, and resources the process uses
the execution unit or thread, containing the execution state and priority, the path of execution the process has taken, a small private memory space and a stack
what is a thread
a subdivision of a process that shares addressable space and resources with the other threads of the process, like variables and files. each thread is its own execution thread
what is multithreading
multithreading is when a process has more than one thread
how do threads of a process run together in multithreading
one thread of a process can run as long as the other threads are blocked, unless the system is a multiprocessor system, in which they can run concurrently
why use threads
creating, destroying, and switching between threads is cheaper than with processes because threads only have their state, stack, and space. additionally, thread intercommunication is cheaper because of their innately shared memory
what are the two types of threads
user threads and kernel threads
what are user threads
threads that aren’t visible by the kernel. this allows operations on these threads to not require system calls, however it also means that one blocked user thread blocks all the user threads on the same kernel thread and that those same user threads cannot run in parallel, ever
what are kernel threads
these are threads that are visible by the kernel, allowing it to individually perceive their execution states and run them in parallel, but requiring that operations on them must use system calls
what are the three types of relationships between kernel and user threads
one-to-one
one-to-many
many-to-many
describe the one-to-one kernel/user thread relation
there is one kernel thread for each user thread, which gives the user thread the same requirements as a kernel thread, but also the same benefits
describe the many-to-one kernel/user thread relation
there are several user threads for one kernel thread. the kernel cannot make a distinction between these user threads, resulting in the same drawbacks and benefits that user threads typically have
describe the many-to-many kernel/user thread relation
many user threads are assigned many kernel threads each, allowing for flexibility in execution. importantly, if one user thread blocks, its other kernel threads can be assigned to another user thread in that ‘knot’
how do fork() and exec() work with threads
forking might copy just the calling thread or all of the process’s threads, depending on the operating system, while exec replaces the program image for all of a process’s threads, because they all share the same image
what are the two types of thread termination
asynchronous cancellation and deferred cancellation
what is asynchronous cancellation of a thread
this ends a thread before it’s finished executing, potentially leaving resources unreleased and shared data in a bad state
what is deferred cancellation of a thread
this uses a flag that the thread will check to see if it needs to terminate, allowing it to end in a safe state
how to solve the issue of a process making an unknown number of threads for an unknown amount of tasks
thread pools, which create a group of threads all at once that will then wait to be assigned tasks. thread pools guarantee both the number of threads and when the creation of these threads will take place