Exam 1 Flashcards
What are the 4 main elements of a computer?
1) Processor (CPU)
2) Primary Storage (RAM)
3) I/O Module
4) System interconnection (bus)
What is the processor (CPU) element of a computer?
controls the operation of the computer and performs its data processing functions
What is the Primary Storage (RAM) element of a computer?
- stores data and programs
- typically volatile memory
What is the I/O Module element of a computer?
- moves data between the computer and its external environments
What is the system bus element of a computer?
provides for communication among processors, main memory, and I/O modules
What are the 2 main processor registers?
1) General Purpose (User-Visible) Registers
2) Control and Status Registers
What are General Purpose (User-Visible) Registers?
- available to both OS and user programs
- hold operands, results, and addresses
What are Control and Status Registers?
- not directly available to user programs
- used by CPU to control its own operation and to control program execution
What is a Program Counter (PC)?
- control and status register
- address of the next instruction to be fetched
What is the Instruction Register (IR)?
- control and status register
- instruction most recently fetched
What is the Program Status Word (PSW)?
- control and status register
- contains status info:
a) condition code bits (zero flag, sign flag, etc.)
b) supervisor/user mode bit
c) interrupt enable/disable bit
What are the 4 types of instructions?
1) Data Movement: transfer data from RAM to CPU (load) or from CPU to RAM (store)
2) Data Manipulation: perform arithmetic or logic operations on data
3) Control Transfer: alter the execution sequence of the program
4) Other: special purpose
What is an interrupt?
- fundamental to operation of modern computers and integral part of OS design
- Mechanism to allow other modules to interrupt CPU
What are the 2 main strategies for handling multiple interrupts?
1) Sequential interrupt processing
2) Nested interrupt processing
What is Sequential interrupt processing?
disables all other interrupts while processing the current interrupt
What is Nested interrupt processing?
allows processing in priority order (each type of interrupt is assigned a relative priority)
What are some examples of classes of interrupts?
- hardware failure (ex: memory parity error)
- Timer (ex: time slice completed)
- I/O (ex: operation completed)
- Program Exception (ex: divide by zero)
- Program Trap: (control transfer instruction to request interrupt)
As one goes down the memory hierarchy, what occurs?
- Decreasing cost per bit
- Increasing capacity
- Increasing access time
- Decreasing frequency of access to the memory by the processor
What is DMA (Direct Memory Access)?
Allow I/O modules to transfer blocks of bytes into (or out of) RAM without using the CPU to copy the bytes
- CPU initiates I/O operation
- I/O module starts processing
- CPU used for other purposes
- I/O uses interrupt to signal completion
What is cache memory?
- small cache of expensive but very fast memory interacting with slower but much larger memory
- processor first checks if word referenced to is in cache
- if not found in cache, a block of memory containing the word is moved to the cache
What is the Locality of Reference?
- memory references for both instructions and data values tend to cluster over a long period of time
- ex: once a loop is entered, there is frequent access to a small set of instructions
- hence: once a byte gets referenced, it is likely that nearby bytes will get referenced often in the near future
What are the differences between a multicore and a multiprocessor system?
multicore: is having multiple processing cores on the same chip, essentially multiple CPUs on one bit on silicon
multiprocessor: is having 2 or more separate CPUs in a machine
What is the distinction between spatial locality and temporal locality?
Spatial locality: refers to the tendency of execution to involve a number of memory locations that are clustered
Temporal locality: refers to the tendency for a processor to access memory locations that have been used recently
In general, what are the strategies for exploiting spatial and temporal locality?
Spatial locality: exploited by using larger cache blocks and by incorporating prefetching mechanisms into the cache control
Temporal locality: exploited by keeping recent used instructions and data values in cache memory and by exploiting a cache hierarchy
What are the 3 objectives of OS design?
1) Convenience
2) Efficiency
3) Ability to evolve
What is the kernel of an OS?
contains the most frequently used functions in the OS and, at a given time, other portions of the OS currently in use
What is microprogramming?
– a.k.a., time sharing, multitasking
– Sharing a resource (e.g., computer) among users, such that each seems to have the whole machine
– Pauses by one user filled with work for another
– Need to store program state, quickly switch among user applications
– Key mechanism: interrupts
What is a process?
- a program in execution
- an instance of a program running on a computer
- the entity that can be assigned to and executed on a processor
- A unit of activity characterized by a single sequential thread of execution, a current state, and an associated set of system resources
List and briefly explain five storage management responsibilities of a typical OS.
1) Process isolation: The OS must prevent independent processes from interfering with each other’s memory, both data and instructions
2) Automatic allocation and management: Programs should be dynamically allocated across the memory hierarchy as required
3) Support of modular programming: Programmers should be able to define program modules, and to create, destroy, and alter the size of modules dynamically
4) Protection and access control: sharing of memory, at any level of the memory hierarchy, creates the potential for one program to address the memory space of another
5) Long-term storage: Many application programs require means for storing information for extended periods of time, after the computer has been powered down
Explain the difference between a real address and a virtual address
real address: the physical address in main memory
virtual address: consists of a page number and an offset within the page
Explain the difference between a monolithic kernel and a microkernel
monolithic kernel: kernel provides most OS services
microkernel: kernel provides as little as possible; user-level servers provide most OS services
What is multithreading?
a technique in which a process, executing an application, is divided into threads that can run concurrently
What is an instruction trace?
characterizes the behavior of an individual process by listing the sequence of instructions that execute for that process
What does it mean to preempt a process?
the reclaiming of a resource from a process before the process has finished using it
What is swapping and what is its purpose?
- involves moving part of all of a process from main memory to the disk
- purpose is to enhance performance
What are the 4 characteristics of a suspended process?
1) The process is not immediately available for execution
2) The process may or may not be waiting on an event. If it is, this blocked condition is independent of the suspend condition, and occurrence of the blocking event does not enable the process to be executed immediately
3) The process was placed in a suspended state by an agent; either itself, a parent process, or the OS, for the purpose of preventing its execution
4) The process may not be removed from this state until the agent explicitly orders the removal
For what types of entities does the OS maintain tables of information for management purposes?
- The allocation of main memory to processes
- The allocation of secondary memory to processes
- Any protection attributes of blocks of main or virtual memory, such as which processes may access certain shared memory regions
- Any information needed to manage virtual memory
What are 3 general categories of information located in a process control block?
1) Process Identification
2) Processor State Information
3) Process Control Information
Why are 2 modes (user and kernel) needed?
It is necessary to protect the OS and key operating system tables, such as process control blocks, form interfering by user programs
What are the steps performed by the OS to create a new process?
1) Assign a unique process identifier to the new process
2) Allocate space for the process
3) Initialize the process control block
4) Set the appropriate linkages
5) Create or expand other data structures
What is the difference between an interrupt and a trap?
interrupt: control is first transferred to an interrupt handler
trap: OS determines if the error or exception condition is fatal. If so, the currently running process is moved to the Exit state and a process switch occurs. If not, then the action of the OS will depend on the nature of the error and design of OS
What is a mode switch?
- system switches modes (ex: user to kernel)
- may happen when an interrupt does not result in a process switch, system needs to save the processor state information
- faster than a process switch
Give 4 general examples of the use of threads in a single-user multiprocessing system
1) Foreground and background work
2) Asynchronous processing
3) Speed of execution
4) Modular program structure
What resources are typically shared by all of the threads of a process?
share the same address space and other resources, such as open files
List 3 advantages of ULTs over KLTs
1) Thread switching does not require kernel mode privileges because all of the thread management data structures are within the user address space of a single process. Therefore, the process does not switch to the kernel mode to do thread management. Saves the overhead of 2 switches
2) Scheduling can be application specific. One application may benefit most from a simple round-robin scheduling algorithm, while another might benefit from a priority-based scheduling algorithm. The scheduling algorithm can be tailored to the application without disturbing the underlying OS scheduler
3) ULTs can run on any OS. No changes are required to the underlying kernel to support ULTs. The threads library is a set of application-level functions shared by all applications
What are 2 disadvantages of ULTs over KLTs?
1) In a typical OS, many system calls are blocking. As a result, when a ULT executes a system call, not only is that thread blocked, but also all of the threads within the process are blocked
2) In a pure ULT strategy, a multithreaded application cannot take advantage of multiprocessing. A kernel assigns 1 process to only 1 processor at a time. Therefore only a single thread within a process can execute at a time. In effect, we have application-level multiprogramming within a single process. While this multiprogramming can result in a significant speedup of the application, there are applications that would benefit from the ability to execute portions of code simultaneously
What is jacketing?
A way to overcome the disadvantages of using ULTs with the purpose of converting a blocking system call into a nonblocking system call
What does the fork() system call do?
– fork() allocates entry in process table and assigns a unique PID to the child process
– child gets a copy of the process image of the parent; both child and parent are executing the same code after fork()
– fork() returns the PID of the child process to the parent process and returns 0 to the child process
What are the benefits of using threads?
- Takes less time to create a new thread than a new process
- Less time to terminate a thread than a process
- Less time to switch between 2 threads within the same process
- Since threads within the same process share memory and files, they can communicate with each other without invoking the kernel
What are advantages of KLTs?
- the kernel can simultaneously schedule many threads of the same process on many processors
- blocking is done on a thread level
- kernel routines can be multithreaded
What are disadvantages of KLTs?
- thread switching within the same process involves the kernel
- this results in a significant overhead
What are 3 problems with Concurrent Execution?
1) Concurrent processes (or threads) often need to share data (in memory or in files)
2) Actions performed by concurrent processes depend on the order in which their execution is interleaved, which typically is not deterministic
3) Must control access to shared data (otherwise data may become corrupted)
List 4 design issues for which the concept of concurrency is relevant
1) The OS must be able to keep track of the various processes. This is done with the use of process control blocks
2) The OS must allocate and deallocate various resources for each active process
3) The OS must protect the data and physical resources of each process against unintended interference by other processes. This involves techniques that relate to memory, files, and I/O devices.
4) The functioning of a process, and the output it produces, must be independent of the speed at which its execution is carried out relative to the speed other concurrent processes
List 3 degrees of awareness between processes
1) Processes unaware of each other
2) Processes indirectly aware of each other
3) Processes directly aware of each other
List the 3 control problems associated with competing processes and the briefly define each
1) Mutual Exclusion: at any time, only one process is allowed to execute in its critical section
2) Deadlock: processes can deadlock if both are waiting on a resource
3) Starvation: a process may be indefinitely denied access to a resource
What operations can be performed on a semaphore?
1) Initialize: A semaphore may be initialized to a nonnegative integer value
2) Decrement: The semWait operation decrements the semaphore value. If the value becomes negative, then the process executing the semWait is blocked. Otherwise the process continues execution
3) Increment: The semSignal operation increments the semaphore value. If the resulting value is less than or equal to 0, then a process blocked by a semWait operation, if any, is unblocked
What is the difference between binary and general semaphores?
a binary semaphore only takes on the values 0 and 1
What is the difference between weak and strong semaphores?
- a weak semaphore does not specify the order in which processes are removed from the queue
- a strong semaphore does
What is a monitor?
a programming language construct that provides equivalent functionality to that of semaphores and that is easier to control
What is a critical section?
when a process executes code that manipulates shared data, we say that the process is in a critical section (CS) for that shared data
What are problems with semaphores?
- Semaphores provide a powerful tool for enforcing mutual exclusion and coordinating processes
- But wait(s) and signal(s) are scattered among several processes. Hence, difficult to understand their effects
- Usage must be correct in all the processes
- One bad (or malicious) process can cause the entire collection of processes to fail