Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Engine 2018

Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

Compiled by S.O.M.M.

Kasinge

Nota bene:

This compilation contains only questions with 99% probability of appearance in the exam
If you want to score 100%, look for the missing questions in other reliable sources
Credit to paul@shaotz, rehema@h.mwawado, lilian@mkonyi, and angelica@kayanda

COMPUTER SYSTEM OVERVIEW


List and briefly define the four main elements of a computer.
 Processor: controls the operation of the computer and performs its data processing functions
 Main memory: Stores both data and instructions. This memory is typically volatile; that is,
when the computer is shut down, the contents of the memory are lost.
 I/O modules: Move data between the computer and its external environment (disks,
communication equipment, terminals)
 System bus: Provides for communication among processors, main memory, I/O modules

Define the two main categories of processor registers.


 User-visible registers: Enable the machine- or assembly-language programmer to minimize
main memory references by optimizing register use. For high-level languages, an optimizing
compiler will attempt to make intelligent choices of which variables to assign to registers and
which to main memory locations. Some high-level languages, such as C, allow the
programmer to suggest to the compiler which variables should be held in registers.
 Control and status registers: Used by the processor to control the operation of the processor
and by privileged, operating system routines to control the execution of programs.

In general terms, what are the four distinct actions that a machine instruction can specify?
 Processor-memory: Data may be transferred from processor to memory or from memory to
processor.
 Processor-I/O: Data may be transferred to or from a peripheral device by transferring
between the processor and an I/O module.
 Data processing: The processor may perform some arithmetic or logic operation on data.
 Control: An instruction may specify that the sequence of execution be altered.

1
Compiled by S.O.M.M. Kasinge

What is an interrupt?
An interrupt is a signal from generated from within the currently executing program or other
modules (I/O, memory) which disrupt the normal sequencing of the processor. It is a signal that
prompts the operating system to stop work on one process and start work on another. When an
interrupt occurs, control is transferred to the operating system, which determines the action to
be taken.

How can multiple interrupts be serviced by setting priorities


Two approaches can be taken to dealing with multiple interrupts.
 The first is to disable interrupts while an interrupt is being processed (Sequential Interrupt
Processing). Two approaches can be taken to dealing with multiple interrupts. The first is to
disable interrupts while an interrupt is being processed
 A second approach (Nested Interrupt Processing) is to define priorities for interrupts and to
allow an interrupt of higher priority to cause a lower-priority interrupt handler to be
interrupted.

What characteristics distinguish the various elements of memory hierarchy?


Access time, capacity and cost per bit

What is cache memory?


Cache memory is a memory that is smaller and faster than main memory and that is interposed
between the processor and main memory. The cache acts as a buffer for recently used memory
locations.

List and briefly define three techniques for I/O operations.


 Programmed I/O: The processor issues an I/O command, on behalf of a process, to an I/O
module; that process then busy-waits for the operation to be completed before proceeding.
 Interrupt-driven I/O: The processor issues an I/O command on behalf of a process, continues
to execute subsequent instructions, and is interrupted by the I/O module when the latter has
completed its work. The subsequent instructions may be in the same process, if it is not
necessary for that process to wait for the completion of the I/O. Otherwise, the process is
suspended pending the interrupt and other work is performed.
 Direct memory access (DMA): A DMA module controls the exchange of data between main
memory and an I/O module. The processor sends a request for the transfer of a block of data
to the DMA module and is interrupted only after the entire block has been transferred.

2
Compiled by S.O.M.M. Kasinge

Give two reasons why caches are useful. What problems do they solve? What problems do they
cause? If a cache can be made as large as the device for which it is caching (for instance, a cache
as large as a disk), why not make it that large and eliminate the device?
 Caches are useful when two or more components need to exchange data, and the
components perform transfers at differing speeds.
 Caches solve the transfer problem by providing a buffer of intermediate speed between
components. If the fast device finds the data it needs in the cache, it need not wait for the
slower device.
 The data in the cache must be kept consistent with the data in the components. If a
component has a data value change, and the datum is also in the cache, the cache must also
be updated. This is especially a problem on multiprocessor systems where more than one
process may be accessing a datum.
 A component may be eliminated by an equal-sized cache, but only if:
(a) The cache and the component have equivalent-saving capacity (that is if the component
retains its data when electricity is removed, the cache must retain data as well), and
(b) The cache is affordable, because faster storage tends to be more expensive.

In a multiprogramming and time-sharing environment, several users share the system


simultaneously. This situation can result in various security problems.
(a) What are two such problems?
(b) Can we ensure the same degree of security in a time-shared machine as in a dedicated
machine? Explain your answer.
(a) Stealing or copying one’s programs or data; using system resources (CPU, memory, disk
space, peripherals) without proper accounting.
One user can read the private data of another user - privacy.
One user can corrupt the private data of another user - integrity.
One user can prevent another user from getting anything done - denial of service.
(b) Probably not, since any protection scheme devised by humans can inevitably be broken by a
human, and the more complex the scheme, the more difficult it is to feel confident of its
correct implementation.

Describe the differences between symmetric and asymmetric multiprocessing. What are three
advantages and one disadvantage of multiprocessor systems?
Symmetric multiprocessing treats all processors as equals, and I/O can be processed on any CPU.
Asymmetric multiprocessing has one master CPU and the remainder CPUs are slaves. The master
distributes tasks among the slaves, and I/O is usually done by the master only.
Multiprocessors can save money by not duplicating power supplies, housings, and peripherals.
They can execute programs more quickly and can have increased reliability. They are also more
complex in both hardware and software than uniprocessor systems.
3
Compiled by S.O.M.M. Kasinge

What is the purpose of interrupts? What are the differences between a trap and an interrupt?
Can traps be generated intentionally by a user program? If so, for what purpose?
An interrupt is a hardware-generated change-of-flow within the system. An interrupt handler is
summoned to deal with the cause of the interrupt; control is then returned to the interrupted
context and instruction. A trap is a software-generated interrupt. An interrupt can be used to
signal the completion of an I/O to obviate the need for device polling. A trap can be used to call
operating system routines or to catch arithmetic errors.

Direct memory access (DMA) is used for high-speed I/O devices in order to avoid increasing the
CPU’s execution load.
a. How does the CPU interface with the device to coordinate the transfer?
b. How does the CPU know when the memory operations are complete?
c. The CPU is allowed to execute other programs while the DMA controller is transferring
data. Does this process interfere with the execution of the user programs? If so, describe what
forms of interference are caused.
The CPU can initiate a DMA operation by writing values into special registers that can be
independently accessed by the device. The device initiates the corresponding operation once it
receives a command from the CPU. When the device is finished with its operation, it interrupts
the CPU to indicate the completion of the operation.

Both the device and the CPU can be accessing memory simultaneously. The memory controller
provides access to the memory bus in a fair manner to these two entities. A CPU might therefore
be unable to issue memory operations at peak speeds since it has to compete with the device in
order to obtain access to the memory bus.

Some computer systems do not provide a privileged mode of operation in hardware. Is it


possible to construct a secure operating system for these computer systems? Give arguments
both that it is and that it is not possible.
An operating system for a machine of this type would need to remain in control (or monitor
mode) at all times. This could be accomplished by two methods:
(a) Software interpretation of all user programs (like some BASIC, Java, and LISP systems, for
example). The software interpreter would provide, in software, what the hardware does not
provide.
(b) Require meant that all programs be written in high-level languages so that all object code is
compiler-produced. The compiler would generate (either in-line or by function calls) the
protection checks that the hardware is missing.

4
Compiled by S.O.M.M. Kasinge

Describe a mechanism for enforcing memory protection in order to prevent a program from
modifying the memory associated with other programs.
The processor could keep track of what locations are associated with each process and limit
access to locations that are outside of a program’s extent. Information regarding the extent of a
program’s memory could be maintained by using base and limits registers and by performing a
check for every memory access.

In virtually all systems that include DMA modules, DMA access to main memory is given higher
priority than processor access to main memory. Why?
If a processor is held up in attempting to read or write memory, usually no damage occurs except
a slight loss of time. However, a DMA transfer may be to or from a device that is receiving or
sending data in a stream (e.g., disk or tape), and cannot be stopped. Thus, if the DMA module is
held up (denied continuing access to main memory), data will be lost.

A computer consists of a CPU and an I/O device D connected to main memory M via a shared
bus with a data bus width of one word. The CPU can execute a maximum of 106 instructions
per second. An average instruction requires five processor cycles, three of which use the
memory bus.
A memory read or write operation uses one processor cycle. Suppose that the CPU is
continuously executing “background” programs that require 95% of its instruction execution
rate but not any I/O instructions.
Assume that one processor cycle equals one bus cycle. Now suppose that very large blocks of
data are to be transferred between M and D.
(a) If programmed I/O is used and each one-word I/O transfer requires the CPU to execute two
instructions, estimate the maximum I/O data transfer rate, in words per second, possible
through D.
(b) Estimate the same rate if DMA transfer is used.

(a) The processor can only devote 5% of its time to I/O. Thus the maximum I/O instruction
execution rate is 106 × 0.05 = 50,000 instructions/second. The I/O transfer rate is therefore
25,000 words/second.
(b) The number of machine cycles available for DMA control is 10^6 × (0.05 × 5 + 0.95 × 2) =
2.15 × 10^6.

5
Compiled by S.O.M.M. Kasinge

OPERATING SYSTEM OVERVIEW


What are three objectives of an OS design?
 Convenience: OS makes computer more convenient to use
 Efficiency: OS allows computer system resources to be used in an efficient manner
 Ability to evolve: OS should be constructed in such a way as to permit effective development,
testing, and introduction of new system functions without interfering with service.

What is the kernel of an OS?


A portion of the operating system that Portion of operating system that is in main memory.
Contains most frequently used functions. The kernel runs in a privileged mode and responds to
calls from process and interrupts from devices.

What is multiprogramming?
When one job needs to wait for I/O, the processor can switch to the other job which is likely not
waiting for I/O, to ensure fully utilization of processor.

What is a process?
A process is a program in execution. It is an instance of a program running on a computer. It is
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.

How is the execution context of a process used by the OS?


The execution context, or process state, is the internal data by which the OS can supervise and
control the process. This internal information is separated from the process, because the OS has
information not permitted to the process. The context includes all the information that the OS
needs to manage the process and that the processor needs to execute the process properly. The
context includes the contents of the various processor registers, such as the program counter
and data registers. It also includes information of use to the OS, such as the priority of the process
and whether the process is waiting for the completion of an I/O event.

6
Compiled by S.O.M.M. Kasinge

List and briefly explain five storage management responsibilities of a typical OS


 Process isolation: OS must prevent independent processes from interfering with each other's
memory, both data and instructions
 Automatic allocation and management: Programs should be dynamically allocated across
memory hierarchy as required. Allocation should be transparent to programmer, so is
relieved of concerns relating to memory limitations, and OS can achieve efficiency by
assigning memory to jobs only as needed
 Support of modular programming: Programmers should be able to define program modules,
and to create, destroy, and alter the size of modules dynamically
 Protection and access control: Sharing of memory, at any level of the memory hierarchy,
creates potential for one program to address memory space of another. This is desirable
when sharing is needed by particular applications. At other times, threatens integrity of
programs and even of OS itself. OS must allow portions of memory to be accessible in various
ways by various users
 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 distinction between the real address and a virtual address.
A logical address is a reference to a memory location independent of the current assignment of
data to memory. It is a combination of page number and an offset within a page. A translation
must be made to a physical address before the memory access can be achieved.
A physical address, or absolute address, is an actual location in main memory.

Describe the round-robin scheduling technique.


Round robin is a scheduling algorithm in which processes are activated in a fixed cyclic order; that
is, all processes are in a circular queue. A process that cannot proceed because it is waiting for
some event (e.g. termination of a child process or an input/output operation) returns control to
the scheduler.

Explain the difference between a monolithic kernel and a microkernel.


Monolithic kernel is a large kernel containing virtually the complete OS, including scheduling, file
system, device drivers, and memory management. All functional components of kernel have
access to all its internal data structures and routines. Typically, a monolithic kernel is
implemented as a single process, with all elements sharing the same address space.

7
Compiled by S.O.M.M. Kasinge

A microkernel architecture assigns only a few essential functions to the kernel, including address
spaces, inter-process communication (IPC), and basic scheduling. Other OS services are provided
by processes, sometimes called servers that run in user mode and are treated like any other
application by the microkernel.

What is multithreading?
Multithreading is a technique in which a process, executing an application, is divided into threads
that can run concurrently.

What are five major activities of an operating system with regard to process management?
 Creating and Deleting of processes: Some of the processes on your computer may run for
short periods of time, with others running continuously over longer periods. The operating
system manages the creation and deletion of all running processes.
 Suspending and Resuming of processes: Although the processes on a computer may appear
to be running continuously, they will often enter paused states for short periods of time. If a
process is not currently executing, for example, if it is waiting for an input or output operation
to complete it may be suspended
 A mechanism for process synchronization: A computer has a finite range of processing
resources that must be shared between all running processes. The operating system carries
out process synchronization to keep any running programs functional and available for user
interaction.
 A mechanism for process communication: In order to keep the running processes
synchronized and receiving the necessary resources, the operating system must be able to
communicate with the processes.
 A mechanism for deadlock handling: When a number of running processes are all in a paused
state, each one waiting for resources currently being used by another running process,
deadlock can occur. The operating system can take steps both to avoid and end deadlock
should it occur.

What are three major activities of an operating system with regard to memory management?
 Keep track of which part of memory are currently being used and by whom.
 Decide which process are loaded into memory when memory space becomes available.
 Allocate and deallocate memory space as needed.

8
Compiled by S.O.M.M. Kasinge

What are three major activities of an operating system with regard to secondary-storage
management?
 Managing the free space available on the secondary-storage device.
 Allocation of storage space when new files have to be written.
 Disk scheduling requests for memory access.

What are five major activities of an operating system with regard to file management?
 The creation and deletion of files.
 The creation and deletion of directions.
 The support of primitives for manipulating files and directions.
 The mapping of files onto secondary storage.
 The backup of files on stable storage media.

What is the purpose of the command interpreter? Why is it usually separate from the kernel?
Command interpreter is an interface of the operating system with the user. It reads commands
from the user or from a file of commands and executes them, usually by turning them into one
or more system calls. It is usually not part of the kernel since multiple command interpreters
(shell, in UNIX terminology) may be supported by an operating system, and they do not really
need to run in kernel mode. Hence the command interpreter is subject to changes.

List five services provided by an operating system, and explain how each creates convenience
for users. In which cases would it be impossible for user-level programs to provide these
services? Explain your answer.
 Program execution: The operating system loads the contents (or sections) of a file into
memory and begins its execution. A user-level program could not be trusted to properly
allocate CPU time.
 I/O operations: Disks, tapes, serial lines, and other devices must be communicated with at a
very low level. The user need only specify the device and the operation to perform on it, while
the system converts that request into device- or controller-specific commands. User-level
programs cannot be trusted to access only devices they should have access to and to access
them only when they are otherwise unused.
 File-system manipulation: There are many details in file creation, deletion, allocation, and
naming that users should not have to perform. Blocks of disk space are used by files and must
be tracked. Deleting a file requires removing the name file information and freeing the
allocated blocks. Protections must also be checked to assure proper file access. User
programs could neither ensure adherence to protection methods nor be trusted to allocate
only free blocks and deallocate blocks on file deletion.

9
Compiled by S.O.M.M. Kasinge

 Communications: Message passing between systems requires messages to be turned into


packets of information, sent to the network controller, transmitted across a communications
medium, and reassembled by the destination system. Packet ordering and data correction
must take place. Again, user programs might not coordinate access to the network device, or
they might receive packets destined for other processes.
 Error detection: Error detection occurs at both the hardware and software levels. By having
errors processed by the operating system, processes need not contain code to catch and
correct all the errors possible on a system

What is the main advantage of the microkernel approach to system design? How do user
programs and system services interact in a microkernel architecture? What are the
disadvantages of using the microkernel approach?
Benefits typically include the following: (a) adding a new service does not require modifying the
kernel, (b) it is more secure as more operations are done in user mode than in kernel mode, and
(c) a simpler kernel design and functionality typically results in a more reliable operating system.
User programs and system services interact in a microkernel architecture by using interprocess
communication mechanisms such as messaging. These messages are conveyed by the operating
system.
The primary disadvantages of the microkernel architecture are the overheads associated with
interprocess communication and the frequent use of the operating system’s messaging functions
in order to enable the user process and the system service to interact with each other.

What are the advantages and disadvantages of using the same system call interface for
manipulating both files and devices?
Advantages: Each device can be accessed as though it was a file in the file system. Since most of
the kernel deals with devices through this file interface, it is easy to add a new device driver by
implementing the hardware-specific code to support this abstract file interface. This benefits the
development of both user program code, which can be written to access devices and files in the
same manner, and device-driver code, which can be written to support a well-defined API.
The disadvantage is that it might be difficult to capture the functionality of certain devices within
the context of the file access API, thereby resulting in either loss of functionality or a loss of
performance. Some of this could be overcome by the use of the ioctl operation that provides a
general purpose interface for processes to invoke operations on devices.

10
Compiled by S.O.M.M. Kasinge

Would it be possible for the user to develop a new command interpreter using the system-call
interface provided by the operating system?
The command interpreter allows a user to create and manage processes and also determine ways
by which they communicate (such as through pipes and files). All of this functionality could be
accessed by a user level program using the system calls; it should be possible for the user to
develop a new command-line interpreter.

What are the two models of inter-process communication? What are the strengths and
weaknesses of the two approaches?
 Shared memory: Reading and writing data to a shared memory.
Strength Is faster than message passing model when the processes are on the same machine
because message passing model requires more system calls.
Weakness: Different processes need to ensure that they are not writing to the same location
simultaneously.
 Message passing: Messages are exchanged between the cooperating processes.
Strength: Easier to implement than shared memory model.

An i/o-bound program is one that, if run alone, would spend more time waiting for i/o than
using the processor. A processor-bound program is the opposite. Suppose a short-term
scheduling algorithm favors those programs that have used little processor time in the recent
past. Explain why this algorithm favors I/O-bound programs. Explain why this algorithm does
not permanently deny processor time to processor-bound programs.
The algorithm favors I/O bound processes because these will be much less likely to have used the
processor recently. As soon as they are done with an I/O burst, they will get to execute on the
processor.
This algorithm does not permanently deny processor time to processor-bound programs,
because once they have been prevented from using the processor for some time they will be
favored by the scheduling algorithm

11
Compiled by S.O.M.M. Kasinge

PROCESS DESCRIPTION AND CONTROL


What is an instruction trace?
A sequence of instructions that execute for a process.

What common events lead to the creation of a process?


New batch job: The OS is provided with a batch job control stream, usually on tape or disk. When
the OS is prepared to take on new work, it will read the next sequence of job control commands.
Interactive logon: A user at a terminal logs on to the system.
Created by OS to provide a service: The OS can create a process to perform a function on behalf
of a user program, without the user having to wait (e.g., a process to control printing).
Spawned by existing process: For purposes of modularity or to exploit parallelism, a user
program can dictate the creation of a number of processes.

What does it mean to preempt a process?


Process preemption occurs when an executing process is interrupted by the processor so that
another process can be executed. To take a resource away from a process. One such resource is
the CPU, and in fact preempt often means to move a process from RUNNING state to READY
state. The process involuntarily gives up the CPU.

What is swapping and what is its purpose?


Swapping involves moving part or all of a process from main memory to disk. To maximize the
number of processes in the system, we swap a process from the ready state to the ready suspend
state (i.e. give its memory to another process).

List four characteristics of a suspended process.


 The process is not immediately available for execution.
 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 execute immediately.
 The process was placed in a suspended state by an agent: itself, a parent process, or the OS,
for the purpose of preventing its execution
 The process may not be removed from this state until the agent explicitly orders the removal.

12
Compiled by S.O.M.M. Kasinge

For what types of entities does the OS maintain tables of information for management
purposes?
 Memory tables are used to keep track of both main (real) and secondary (virtual) memory.
Some of main memory is reserved for use by the OS; the remainder is available for use by
processes.
 I/O tables: Used by the OS to manage the I/O devices and channels of the computer.
 File tables: These tables provide information about existence of files, location on secondary
memory and current Status
 Process tables: To manage processes the OS needs to know details of the processes current
state, process ID, location in memory.

List three general categories of information in a process control block.


 Process identification: In virtually all operating systems each process is assigned to a unique
numeric identifier.
 Processor state information: Content of processor registers. While a process is running,
 Process control information - additional info needed by the OS to control and coordinate
various active processes

Why are two modes (user and kernel) needed?


To protect the OS and key OS tables such as process control block from interference by user
programs. It is necessary to protect the OS and key operating system tables, such as process
control blocks, from interference by user programs. In kernel mode, the software has complete
control of the processor and all its instructions, registers and memory. This level of a control is
not necessary and for safety is not desirable for user programs

What are the steps performed by an OS to create a new process?


 Assign a unique process identifier
 Allocate space for the process
 Initialize process control block
 Set up appropriate linkages ex: add new process to linked list used for scheduling queue
 Create of expand other data structures ex: maintain an accounting file

13
Compiled by S.O.M.M. Kasinge

What is the difference between an interrupt and a trap?


Interrupt is caused by external to the execution of the current instruction, and is used to react to
an asynchronous external event.
Trap is associated with the execution of the current instruction, and is used for handling of an
error or an exception condition

Give three examples of an interrupt.


Clock interrupt: The OS determines whether the currently running process has been executing
for the maximum allowable unit of time, referred to as a time slice
I/O interrupt: The OS determines what I/O action has occurred. The OS must then decide
whether to resume execution of the process currently in the Running state or to preempt that
process for a higher-priority Ready process
Memory fault: The processor encounters a virtual memory address reference for a word that is
not in main memory. The OS must bring in the block (page or segment) of memory containing
the reference from secondary memory to main memory

What is the difference between a mode switch and a process switch?


Process switch - Process changes state between the status like read, blocked, suspend
Model switch - The CPU changes privileged levels. A mode switch may occur without changing
the state of the process that is currently in the Running state

Consider a computer with N processors in a multiprocessor configuration.


(a) How many processes can be in each of the Ready, Running, and Blocked states at one time?
(b) What is the minimum number of processes that can be in each of the Ready, Running, and
Blocked states at one time?
There can be N processes in running state. The number of processes in ready and blocked state
depends on the size of "ready list" and "blocked list".
The minimum number of processes can be 0, if the system is idle and there are no blocked jobs
or no ready jobs.

14
Compiled by S.O.M.M. Kasinge

THREADS, SMP AND MICROKERNELS

List reasons why a mode switch between threads may be cheaper than a mode switch between
processes.
Switching process requires OS to process more information.
Memory is shared by threads, so there's no need to exchange memory or data during thread
creation or switching. Thread switching does not require kernel to get involved, which in turn
saves time on switching user to kernel mode

What are the two separate and potentially independent characteristics embodied in the
concept of process?
Resource ownership: A process includes a virtual address space to hold the process image. From
time to time, a process may be allocated control or ownership of resources, such as main
memory, I/O channels, I/O devices, and files. The OS performs a protection function to prevent
unwanted interference between processes with respect to resources.
Scheduling/execution: The execution of a process follows an execution path (trace) through one
or more programs. This execution may be interleaved with that of other processes. Thus, a
process has an execution state (Running, Ready, etc.) and a dispatching priority and is the entity
that is scheduled and dispatched by the OS.

Give four general examples of the use of threads in a single-user multiprocessing system.
 Foreground and background work: For example, in a spreadsheet program, one thread could
display menus and read user input, while another thread executes user commands and
updates the spreadsheet. This arrangement often increases the perceived speed of the
application by allowing the program to prompt for the next command before the previous
command is complete.
 Asynchronous processing: Asynchronous elements in the program can be implemented as
threads. For example, as a protection against power failure, one can design a word processor
to write its random access memory (RAM) buffer to disk once every minute. A thread can be
created whose sole job is periodic backup and that schedules itself directly with the OS; there
is no need for fancy code in the main program to provide for time checks or to coordinate
input and output.
 Speed of execution: A multithreaded process can compute one batch of data while reading
the next batch from a device. On a multiprocessor system, multiple threads from the same
process may be able to execute simultaneously. Thus, even though one thread may be
blocked for an I/O operation to read in a batch of data, another thread may be executing.

15
Compiled by S.O.M.M. Kasinge

 Modular program structure: Programs that involve a variety of activities or a variety of


sources and destinations of input and output may be easier to design and implement using
threads.

What resources are typically shared by all of the threads of a process?


All of the threads of a process share the state and resources of that process. They reside in the
same address space and have access to the same data. When one thread alters an item of data
in memory, other threads see the results if and when they access that item. If one thread opens
a file with read privileges, other threads in the same process can also read from that file.

List three advantages of ULTs over KLTs.


 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. This saves the
overhead of two mode switches (user to kernel; kernel back to user).
 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.
 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

List two disadvantages of ULTs compared to KLTs.


 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.
 In a pure ULT strategy, a multithreaded application cannot take advantage of multiprocessing.
A kernel assigns one process to only one 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.

16
Compiled by S.O.M.M. Kasinge

List the key design issues for an SMP operating system.


 Simultaneous concurrent processes or threads: Kernel routines need to be reentrant to
allow several processors to execute the same kernel code simultaneously.
 Scheduling: Scheduling may be performed by any processor, so conflicts must be avoided.
 Synchronization: With multiple active processes having potential access to shared address
spaces or shared I/O resources, care must be taken to provide effective synchronization
 Memory Management: Memory management on a multiprocessor must deal with all of the
issues found on uniprocessor machines. There is a problem with the cache memories: Cache
memories contain image of a portion of main memory. If a processor changes the contents
of the main memory, these changes have to be recorded in the cache memories that contain
an image of that portion of memory. This is known as cache coherence problem and is
typically solved in hardware.
 Reliability and fault tolerance: The operating system should provide graceful degradation in
the face of processor failure

Give examples of services and functions found in a typical monolithic OS that may be external
subsystems to a microkernel OS
 Device drivers,
 File systems,
 Virtual memory manager,
 Windowing system,
 Security services.

List and briefly explain seven potential advantages of a microkernel design compared to a
monolithic design.
 Uniform interfaces: processes need not distinguish between kernel-level and user-level
services because all such services are provided by means of message passing.
 Extensibility: Allowing the addition of new services as well as the provision of multiple
services in the same functional area.
 Flexibility: Not only can new features be added to the operating system, but existing features
can be subtracted to produce a smaller, more efficient implementation.
 Portability: All or least much of the processor-specific code is in the microkernel. Changes
needed to port the system to a new processor are fewer and tend to be arranged in logical
groupings.
 Reliability: A small microkernel can be rigorously tested. Its use of a small number of
application programming interfaces (APIs) improves the chance of producing quality code for
the operating system services outside the kernel

17
Compiled by S.O.M.M. Kasinge

 Distributed system support: Message are sent without knowing what the target machine is
 Object-oriented operating system: Components are objects with clearly defined interfaces
that can be interconnected to form software

Explain the potential performance disadvantage of a microkernel OS.


One potential disadvantage of microkernels is that of performance. It takes longer to build and
send a message via the microkernel, and accept and decode the reply, than to make a single
service call.
Performance depends on the size of the microkernel - a very small microkernel improves
flexibility and reliability.

List three functions you would expect to find even in a minimal microkernel OS.
 Low-level memory management,
 Inter-process communication (IPC), and
 I/O and interrupt management

What is the basic form of communications between processes or threads in a microkernel OS?
Message

CONCURRENCY: MUTUAL EXCLUSION AND SYNCHRONIZATION

List three degrees of awareness between processes and briefly define each.
 Processes unaware of each other: These are independent processes that are not intended to
work together. Although the processes are not working together, the OS needs to be
concerned about competition for resources. For example, two independent applications may
both want access the same disk or file or printer. The OS must regulate these accesses.
 Process indirectly ware of each other: These are processes that are not necessarily aware of
each other by their respective process IDs but that share access to some object, such as an
I/O buffer. Such processes exhibit cooperation in sharing the common object.
 Processes directly aware of each other: These are processes that are able to communicate
with each other by process ID and that are designed to work jointly on some activity. Again,
such processes exhibit cooperation

18
Compiled by S.O.M.M. Kasinge

What is the distinction between competing processes and cooperating processes?


Competition: Two or more processes need to access a resource during the course of their
execution. Each process is unaware of the existence of the other processes, and each is to be
unaffected by the execution of the other processes. It follows from this that each process should
leave the state of any resource that is uses unaffected.
Cooperation: Processes may have access to shared data without reference to other processes
but know that other processes may have access to the same data. Thus the processes must
cooperate to ensure that the data they share are properly managed. When processes cooperate
by communication the various processes participate in a common effort that links all of the
processes. The communication provides a way to synchronize, or coordinate, the various
activities.

List the three control problems associated with competing processes and briefly define each.
Mutual exclusion: Suppose two or more processes require access to a single non-sharable
resource, such as a printer. During the course of execution, each process will be sending
commands to the I/O device, receiving status information, sending data, and/or receiving data.
We will refer to such a resource as a critical resource, and the portion of the program that uses
it a critical section of the program. It is important that only one program at a time be allowed in
its critical section.
Deadlock: For example, consider two processes, P1 and P2, and two resources, R1 and R2.
Suppose that each process needs access to both resources to perform part of its function. Then
it is possible to have the following situation: the OS assigns R1 to P2, and R2 to P1. Each process
is waiting for one of the two resources. Neither will release the resource that it already owns
until it has acquired the other resource and performed the function requiring both resources.
Starvation: The OS may grant access to resources to a number of processes while neglecting
another

List the requirements for mutual exclusion


 Mutual exclusion must be enforced: Only one process at a time is allowed into its critical
section, among all processes that have critical sections for the same resource or shared
object.
 A process that halts in its noncritical section must do so without interfering with other
processes.
 It must not be possible for a process requiring access to a critical section to be delayed
indefinitely: no deadlock or starvation.

19
Compiled by S.O.M.M. Kasinge

 When no process is in a critical section, any process that requests entry to its critical section
must be permitted to enter without delay.
 No assumptions are made about relative process speeds or number of processors.
 A process remains inside its critical section for a finite time only.

Explain why Windows, Linux, and Solaris implement multiple locking mechanisms. Describe the
circumstances under which they use spinlocks, mutex locks, semaphores, adaptive mutex
locks, and condition variables. In each case, explain why the mechanism is needed.
These operating systems provide different locking mechanisms depending on the application
developers’ needs. Spinlocks are useful for multiprocessor systems where a thread can run in a
busy-loop (for a short period of time) rather than incurring the overhead of being put in a sleep
queue. Mutexes are useful for locking resources. Solaris 2 uses Adaptive mutexes, meaning that
the mutex is implemented with a spin lock on multiprocessor machines. Semaphores and
condition variables are more appropriate tools for synchronization when a resource must be held
for a long period of time, since spinning is inefficient for a long duration

What is the meaning of the term busy waiting? What other kinds of waiting are there in an
operating system? Can busy waiting be avoided altogether? Explain your answer.
Busy waiting means that a process is waiting for a condition to be satisfied in a tight loop without
relinquishing the processor. Alternatively, a process could wait by relinquishing the processor,
and block on a condition and wait to be awakened at some appropriate time in the future.
Busy waiting can be avoided but incurs the overhead associated with putting a process to sleep
and having to wake it up when the appropriate program state is reached

What operations can be performed on a semaphore?


 A semaphore may be initialized to a nonnegative integer value.
 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.
 The semSignal operation increments the semaphore value. If the resulting value is less than
or equal to zero, then a process blocked by a semWait operation, if any, is unblocked

What is the difference between binary and general semaphores?


A semaphore is an integer value used for signaling among processes. A binary semaphore is a
semaphore that only takes the values 0 and 1.

20
Compiled by S.O.M.M. Kasinge

The Linux kernel has a policy that a process cannot hold a spinlock while attempting to acquire
a semaphore. Explain why this policy is in place.
You cannot hold a spin lock while you acquire a semaphore, because you might have to sleep
while waiting for the semaphore, and you cannot sleep while holding a spin lock
What is the difference between strong and weak semaphores?
A strong semaphore includes FIFO policy to remove processes from the queue, such that the
process that has been blocked the longest is released from the queue first.
A semaphore that does not specify the order in which processes are removed from the queue is
a weak semaphore.

What is a monitor?
Is a programming language construct that encapsulates variables, access procedures and
initialization code within an abstract data type. The monitor’s variable may only be accessed via
its access procedures and only one process may be actively accessing the monitor at any one
time. The monitor is a programming-language construct that provides equivalent functionality to
that of semaphores and that is easier to control. They both provide mechanism for enforcing
mutual exclusion and for coordinating processes.

What is the distinction between blocking and nonblocking with respect to messages?
Blocking send, blocking receive: Both the sender and receiver are blocked until the message is
delivered; this is sometimes referred to as a rendezvous. This combination allows for tight
synchronization between processes.
Nonblocking send, blocking receive: Although the sender may continue on, the receiver is
blocked until the requested message arrives. This is probably the most useful combination. It
allows a process to send one or more messages to a variety of destinations as quickly as possible.
A process that must receive a message before it can do useful work needs to be blocked until
such a message arrives. An example is a server process that exists to provide a service or resource
to other processes.
Nonblocking send, nonblocking receive: Neither party is required to wait.

21
Compiled by S.O.M.M. Kasinge

CONCURRENCY: DEADLOCK AND STARVATION

Differentiate between reusable and consumable resources.


A reusable resource is one that can be safely used by only one process at a time and is not
depleted by that use. Processes obtain resource units that they later release for reuse by other
processes. Examples of reusable resources include processors, I/O channels, main and secondary
memory, devices, and data structures such as files, databases, and semaphores.
A consumable resource is one that can be created (produced) and destroyed (consumed).
Examples of consumable resources are interrupts, signals, messages, and information in I/O
buffers.

What are the three conditions that must be present for deadlock to be possible?
In order for deadlock to be possible, the following three conditions must be present in the
computer:
 Mutual exclusion: only one process may use a resource at a time
 Hold-and-wait: a process may hold allocated resources while awaiting assignment of others
 No preemption: no resource can be forcibly removed from a process holding it

What are the four conditions that create deadlock?


 Mutual exclusion
 Hold-and-wait
 No preemption
 Circular wait. A closed chain of processes exists, such that each process holds at least one
resource needed by the next process in the chain.

How can the hold-and-wait condition be prevented?


The hold-and-wait condition can be prevented by requiring that a process request all of its
required resources at one time and blocking the process until all requests can be granted
simultaneously. Alternatively, if a process requests a resource that is currently held by another
process, the OS may preempt the second process and require it to release its resources.

22
Compiled by S.O.M.M. Kasinge

List two ways in which the no-preemption condition can be prevented.


First, if a process holding certain resources is denied a further request, that process must release
its original resources and, if necessary, request them again together with the additional resource.
Alternatively, if a process requests a resource that is currently held by another process, the OS
may preempt the second process and require it to release its resources.

How can the circular wait condition be prevented?


The circular-wait condition can be prevented by defining a linear ordering of resource types. If a
process has been allocated resources of type R, then it may subsequently request only those
resources of types following R in the ordering.

What is the difference among deadlock avoidance, detection, and prevention?


Deadlock prevention, the goal is to ensure that at least one of the necessary conditions for
deadlock can never hold. We constrain resource requests to prevent at least one of the four
conditions of deadlock. This is either done indirectly, by preventing one of the three necessary
policy conditions (mutual exclusion, hold and wait, no preemption), or directly by preventing
circular wait.
Deadlock avoidance, the goal is to ensure the system must not enter an unsafe state. We can
allow the three necessary conditions but makes judicious choices to assure that the deadlock
point is never reached.
Deadlock detection, the goal is to detect the deadlock after it occurs or before it occurs.
Requested resources are granted to processes whenever possible. Periodically, the OS performs
an algorithm that allows it to detect the circular wait condition.

List three examples of deadlocks that are not related to a computer system environment.
 Two cars crossing a single-lane bridge from opposite directions.
 A person going down a ladder while another person is climbing up the ladder.
 Two trains traveling toward each other on the same track.
 Two carpenters who must pound nails. There is a single hammer and a single bucket of nails.
Deadlock occurs if one carpenter has the hammer and the other carpenter has the nails.

Can a system detect that some of its processes are starving? If you answer “yes,” explain how
it can. If you answer “no,” explain how the system can deal with the starvation problem.

23
Compiled by S.O.M.M. Kasinge

For the purposes of this question, we will define starvation as the situation whereby a process
must wait beyond a reasonable period of time T, perhaps indefinitely before receiving a
requested resource. One way of detecting starvation would be to first identify a period of time
that is considered unreasonable. When a process requests a resource, a timer is started. If the
elapsed time exceeds T, then the process is considered to be starved.
One strategy for dealing with starvation would be to adopt a policy where resources are assigned
only to the process that has been waiting the longest.

MEMORY MANAGEMENT:
What requirements memory management required to satisfy?
 Relocation - A process that has been swapped out to a disk can be moved to a different
memory location than the one it was in previously.
 Protection - Each process should be protected from unwanted interference by other
processes, so programs in other processes should not be able to reference memory locations
in a process for reading or writing purposes without permission; satisfied by the processor
(hardware)
 Sharing - Allowing several processes to access the same portion of main memory. Memory
management system must allow controlled access to shared areas of memory without
compromising essential protection
 Logical organization - Enabling the OS and computer hardware to deal with user programs
and data in the form of modules of some sort
 Physical organization - The organization of the flow of information between main and
secondary memory

Why is the capability to relocate processes desirable?


In a multiprogramming system, the available main memory is generally shared among a number
of processes. Typically, it is not possible for the programmer to know in advance which other
programs will be resident in main memory at the time of execution of his or her program. In
addition, we would like to be able to swap active processes in and out of main memory to
maximize processor utilization by providing a large pool of ready processes to execute.
Once a program has been swapped out to disk, it would be quite limiting to declare that when
it is next swapped back in, it must be placed in the same main memory region as before. Instead,
we may need to relocate the process to a different area of memory.

24
Compiled by S.O.M.M. Kasinge

Why it is not possible to enforce memory protection at compile time?


The OS cannot anticipate all the memory references a program will make, and even if it could, it
would be prohibitively time consuming to screen each program in advance for possible memory-
reference violations.

What are some reasons to allow two or more processes to all have access to a particular region
of memory?
If a number of processes are executing the same program, it is advantageous to allow each
process to access the same copy of the program rather than have its own copy. Processes that
are cooperating on some task may need to share access to the same data structure.

In fixed partitioning scheme, what are the advantages of using un-equal sized partition
scheme?
Processes are assigned in such a way as to minimize wasted memory within a partition (internal
fragmentation). Larger programs can be accommodated without overlay.

What is the difference between internal and external fragmentation?


Internal fragmentation mean there is wasted space internal to a partition due to the fact that
the block of data loaded is smaller than the partition.
External fragmentation occurs when memory is allocated and a small piece is left over that
cannot be effectively used (memory that is external to all partitions become increasingly
fragmented)

What is the distinction between logical, relative and physical addresses?


A logical address is a reference to a memory location independent of the current assignment of
data to memory; a translation must be made to a physical address before the memory access can
be achieved.
A relative address is a particular example of logical address, in which the address is expressed as
a location relative to some known point, usually a value in a processor register.
A physical address is an actual location in main memory.

25
Compiled by S.O.M.M. Kasinge

What is the difference between a page and a frame?


A is a fixed-length block of main memory. It is a part of a process, while a frame is a part of
memory.

What is the difference between a page and a segment?


With segmentation a program may occupy more than one partition, and these partitions need
not be contiguous. Segmentation is visible to the programmer and is provided as a convenience
for organizing programs and data, while paging is invisible to the programmer.

Describe the page placement algorithms memory management.


Best-fit algorithm: Chooses the block that is closest in size to the request
First Fit algorithm: Scans memory form the beginning and chooses the first available block that
is large enough
Next-fit: Scans memory from the location of the last placement. More often allocate a block of
memory at the end of memory where the largest block is found

VIRTUAL MEMORY
What is the difference between simple paging and virtual memory paging?
Both are memory management (partitioning) techniques.
Simple Paging: Main memory is divided into a number of equal-size frames. Each process is
divided into a number of equal-size pages of the same length as frames. A process is loaded by
loading all of its pages into available, not necessarily contiguous, frames.
Virtual Memory Paging: As with simple paging, except that it is not necessary to load all of the
pages of a process. Nonresident pages that are needed are brought in later automatically.

Explain Thrashing.
Thrashing is when the system spends most of its time swapping pieces of a process rather than
executing instructions. To overcome this, the OS essentially guesses which pieces are least likely
to be used in the near future, based on recent history, and will swap those out of main memory.

Why is the principle of locality crucial to the use of virtual memory?


The principle of locality states that program and data references within a process tend to cluster.
This validates the assumption that only a few pieces of a process are needed over a short period

26
Compiled by S.O.M.M. Kasinge

of time. This also means that it should be possible to make intelligent guesses about which pieces
of a process will be needed in the near future, which avoids thrashing. These two things mean
that virtual memory is an applicable concept and that it is worth implementing.

What elements are typically found in a page table entry? Briefly define each element.
 Frame number: Which contains the frame number of the corresponding page in main
memory
 A present (P) bit: Which indicates whether the corresponding page is in main memory or not.
 A modify (M) bit: Which indicates whether the contents of the corresponding page have been
altered since the page was last loaded into main memory.

Briefly define the alternative page fetch policies.


Determines when a page should be brought into memory. They are;
Demand paging - A page is brought into main memory only when a reference is made to a
location on that page.
Prepaging - Pages other than the one demanded by a page fault are brought in.

What is the difference between resident set management and page replacement policy?
Resident set management - how many page frames are to be allocated to each active process,
and whether the set of pages to be considered for replacement should be limited to those of the
process that caused the page fault or encompass all the page frames in main memory.
Replacement policy - Among the set of pages considered, which particular page should be
selected for replacement.

27
Compiled by S.O.M.M. Kasinge

Describe the four basic page replacement algorithms.


 Optimal: This policy selects for replacement that page for which the time to the next
reference is the longest.
 Least recently used (LRU): Replaces the page that has not been referenced for the longest
time. By the principle of locality, this should be the page least likely to be referenced in the
near future
 First-in-first-out (FIFO): Treats page frames allocated to a process as a circular buffer. Pages
are removed in round-robin style. Page that has been in memory the longest is replaced.
 Clock: Uses and additional bit called a “use bit”. When a page is first loaded in memory or
referenced, the use bit is set to 1. When it is time to replace a page, the OS scans the set
flipping all 1’s to 0. The first frame encountered with the use bit already set to 0 is replaced.

What is the relationship between FIFO and Clock page replacement algorithms?
Both treat the page frames allocated to a process as a circular buffer, with which a pointer is
associated.

What is accomplished by page buffering?


Page buffering essentially creates a cache of pages by assigning a replacement page to one of
two lists: the free page list or the modified page list. The page to be replaced remains in memory.

Why is it not possible to combine a global replacement policy and a fixed allocation policy?
A fixed allocation policy gives a process a fixed number of frames in main memory. This number
is decided at initial load time (process creation time). In this policy, when a page fault occurs in
the execution of a process, one of the pages of that process must be replaced.
A global replacement policy considers all unlocked pages in main memory as candidates for
replacement, regardless of which process owns a particular page.

What is the difference between a resident set and a working set?


The resident set is the portion of a process that is actually in main memory at any time. A working
set is the set of pages of a process that have been referenced within a certain time period.

28
Compiled by S.O.M.M. Kasinge

What is the difference between demand cleaning and precleaning?


A cleaning policy is the opposite of a fetch policy: it is concerned with determining when a
modified page should be written out to secondary memory.
With demand cleaning: A page is written out to secondary memory only when it has been
selected for replacement.
A pre cleaning policy: Writes modified pages before their page frames are needed so that pages
can be written out in batches.

Under what circumstances do page faults occur? Describe the actions taken by the operating
system when a page fault occurs.
A page fault occurs when an access to a page that has not been brought into main memory takes
place. The operating system verifies the memory access, aborting the program if it is invalid. If it
is valid, a free frame is located and I/O is requested to read the needed page into the free frame.
Upon completion of I/O, the process table and page table are updated and the instruction is
restarted.

UNIPROCESSOR SCHEDULING

Briefly describe the three types of processor scheduling.


 Long-term: Is the decision to add to the pool of processes to be executed. Is performed when
a new process is created.
 Medium-term: part of swapping function. This is a decision whether to add a process to those
that are at least partially in main memory and therefore available for execution.
 Short-term: Also known as the dispatcher, is the decision as to which available process will
be executed by the processor.

What is usually the critical performance requirement in an interactive OS?


In most interactive operating systems, whether single user or time shared, adequate response
time is the critical performance requirement.

What is the difference between turnaround time and response time?


Turnaround time is the interval between the submission of a process and its completion. Includes
actual execution time plus time spent waiting for resources, including the processor. It is an
appropriate measure for a batch job).

29
Compiled by S.O.M.M. Kasinge

Response time is the time from the submission of a request until the response begins to be
received. Often a process can begin producing some output to the user while continuing to
process the request Thus, this is a better measure than turnaround time from the user's point of
view.

For process scheduling, does a low-priority value represent a low priority or a high priority?
In UNIX and many other systems, lower priority values represent higher priority processes.

What is the difference between preemptive and non-preemptive scheduling?


Preemptive: The currently running process may be interrupted and moved to the Ready state by
the OS. Preemption may occur when new process arrives, on an interrupt, or periodically (based
on clock interrupt).
Nonpreemptive: Once a process is in the Running state, it continues to execute until it terminates
or it blocks itself to wait for I/O or to request some OS service.

Describe basic types of uniprocessor scheduling policies.


 First-Come-First-Served: Also known as FIFO. As each process becomes ready, it joins the
ready queue. When the currently running process ceases to execute, the process that has
been in the ready queue the longest is selected for running. First-Come-First-Serve performs
much better for long processes than short ones.
 Round-robin scheduling: It incorporates the use of preemption based on a clock. This
technique is known as time slicing, because each process is given a slice of time before being
preempted. The clock interrupt is generated at periodic intervals, and when it occurs, the
currently running process is placed in the ready queue, and the next ready job is selected on
a FCFS basis.
 Shortest Process Next: A non-preemptive policy in which the process with the shortest
expected processing time is selected next. A short process will jump to the head of the queue
past longer jobs.
 Shortest Remaining Time: It is a preemptive version of shortest-process-next. The scheduler
always chooses the process that has the shortest expected remaining process time. As with
SPN, there is a risk of starvation of longer processes.
 Highest Response Ratio Next: In this, a formula determines which process is chosen next.
When the current process completes or is blocked, you choose the ready process with the
greatest response ratio value. While shorter jobs are favored, aging without service increases
the ratio so that a longer process will eventually get past competing shorter jobs.
 Feedback Scheduling: This is used if there is no indication of the length of various processes.
Feedback scheduling penalizes jobs that have been running longer. Hierarchical queues are
used to keep track of how long processes are taking.

30
Compiled by S.O.M.M. Kasinge

MULTIPROCESSOR and REAL-TIME SCHEDULLING

List and briefly define five different categories of synchronization granularity.


 Independent Parallelism: No explicit synchronization among processes. Each represents a
separate, independent application or job. Example is time-sharing system
 Coarse Parallelism: With coarse and very-coarse grained parallelism, there is synchronization
among processes, but at a very gross level. Good for concurrent processes running on a
multiprogrammed uniprocessor.
 Very Coarse-Grained Parallelism
 Medium-Grained Parallelism: Parallel processing within a single application. Threads usually
interact frequently, affecting the performance of the entire application.
 Fine-Grained Parallelism: Parallelism inherent in a single instruction stream.

List and briefly define four techniques for thread scheduling.


 Load sharing - Processes are not assigned to a particular processor. A global queue of ready
threads is maintained, and each processor, when idle, selects a thread from the queue.
 Gang scheduling - A set of related threads is scheduled to run on a set of processors at the
same time, on a one-to-one basis. Parallel execution of closely related processes may reduce
overhead such as process switching and synchronization blocking.
 Dedicated processor assignment - The opposite of load-sharing, this approach provides
implicit scheduling defined by the assignment of threads to processors. Parallel execution of
closely related processes may reduce overhead such as process switching and
synchronization blocking.
 Dynamic scheduling - The number of threads in a process can be altered during the course of
execution. This allows the OS to adjust the load to improve utilization.

List and briefly define three versions of load sharing.


 First come first served (FCFS) - When a job arrives, each of its threads is placed consecutively
at the end of the shared queue. When a processor becomes idle, it picks the next ready
thread, which it executes until completion or blocking.
 Smallest number of threads first - The shared ready queue is organized as a priority queue,
with threads from jobs with the smallest number of unscheduled threads given highest
priority. Jobs with equal priority are ordered according to which job arrives first. As with FCFS,
a scheduled thread is run to completion or blocking.

31
Compiled by S.O.M.M. Kasinge

 Preemptive smallest number of threads first - Highest priority is given to jobs with the
smallest number of unscheduled threads. An arriving job with a smaller number of threads
than an executing job will preempt threads belonging to the scheduled job.

What is the difference between hard and soft real-time tasks?


A hard real-time task is one that must meet its deadline; otherwise it will cause unacceptable
damage or a fatal error to the system.
A soft real-time task has an associated deadline that is desirable but not mandatory; it still makes
sense to schedule and complete the task even if it has passed its deadline.

List and briefly define five general areas of requirements for a real-time Operating System.
 Determinism - An OS is deterministic to the extent that it performs operations at fixed,
predetermined times or within predetermined time intervals.
 Responsiveness - Concerned with how long, after acknowledgment, it takes an OS to service
an interrupt. Responsiveness includes amount of time to begin execution of the interrupt and
amount of time to perform the interrupt.
 User control - In a real-time system, it is essential to allow the user fine-grained control over
task priority. The user should be able to distinguish between hard and soft tasks and to specify
relative priorities within each class.
 Reliability - Loss or degradation of performance in a real-time system can have catastrophic
consequences, because a real-time system is responding to and controlling events in real
time.
 Fail-soft operation - refers to the ability of a system to fail in such a way as to preserve as
much capability and data as possible.

List and briefly define four classes of real-time scheduling algorithms.


 Static table-driven approach - perform a static analysis of feasible schedules of dispatching.
The result is a schedule that determines, at run time, when a task must begin execution.
 Static priority-driven preemptive approach - a static analysis is performed, but no schedule
is made. Rather, the analysis is used to assign priorities to tasks so that a traditional priority-
driven preemptive scheduler can be used.
 Dynamic planning-based approach - Feasibility is determined at run time (dynamically)
rather than offline prior to the start of execution (statically). An arriving task is accepted for
execution only if it is feasible to meet its time constraints.
 Dynamic best effort approach - No feasibility analysis is performed. The system tries to meet
all deadlines and aborts any started process whose deadline is missed.

32
Compiled by S.O.M.M. Kasinge

What items of information about a task might be useful in real-time scheduling?


Ready time - The time at which a task is ready for execution.
Starting deadline - Time by which a task must begin.
Completion deadline - Time by which task must be completed. The typical real-time application
will either have starting or completion deadlines, but not both.
Processing time - Time required to execute the task to completion. In some cases, this is supplied.
In others, the OS measures an exponential average. For still other scheduling systems, this info is
not used.
Resource requirements - Set of resources (other than the processor) required by the task while
it is executing.
Priority - Measures relative importance of the task.
Subtask structure - A task may be decomposed into a mandatory subtask and an optional
subtask. Only the mandatory subtask possesses a hard deadline.

I/O MEMORY MANAGEMENT and DISK SCHEDULLING

List and briefly define three techniques for performing I/O.


 Programmed I/O - The processor issues an I/O command, on behalf of a process, to an I/O
module; that process then busy waits for the operation to be completed before proceeding.
 Interrupt-driven I/O - The processor issues an I/O command on behalf of a process. There
are then two possibilities. If the I/O instruction from the process is nonblocking, then the
processor continues to execute instructions from the process that issued the I/O command.
If the I/O instruction is blocking, then the next instruction that the processor executes is from
the OS, which will put the current process in a blocked state and schedule another process.
 Direct memory access (DMA) - A DMA module controls the exchange of data between main
memory and an I/O module. The processor sends a request for the transfer of a block of data
to the DMA module and is interrupted only after the entire block has been transferred.

What is the difference between logical I/O and device I/O?


Logical I/O - Deals with the device as a logical resource and is not concerned with the details of
actually controlling the device. Concerned with managing general I/O functions on behalf of user
processes.
Device I/O - The requested operations and data are converted into appropriate sequences of I/O
instructions, channel commands, and controller orders.

33
Compiled by S.O.M.M. Kasinge

What is the difference between block-oriented devices and stream-oriented devices? Give a
few examples of each.
A block-oriented device stores info in blocks that are usually of fixed size, and transfers are made
one block at a time. Generally, it is possible to reference data by its block number. Disks and USB
keys are examples of these devices.
A stream-oriented device transfers data in and out as a stream of bytes, with no block structure.
Terminals, printers, mouse and other pointing devices, and most other devices that are not
secondary storage are stream oriented.

How does DMA increase system concurrency? How does it complicate hardware design?
DMA increases system concurrency by allowing the CPU to perform tasks while the DMA system
transfers data via the system and memory buses. Hardware design is complicated because the
DMA controller must be integrated into the system and the system must allow the DMA
controller to be a bus master. Cycle stealing may also be necessary to allow the CPU and DMA
controller to share use of the memory bus.

Why would you expect improved performance using a double buffer rather than a single buffer
for I/O?
Because a process is now transferring data to (or from) one buffer while the OS empties (or fills)
the other.

What delay elements are involved in a disk read or write?


Seek time: the time required to move disk arm to the required track.
Rotational delay: the time required for the addressed area of the disk to rotate into a position
where it is accessible by the read/write head.
Access time: Seek time + rotational delay.
Transfer time: the time required for the data transfer.

When multiple interrupts from different devices appear at about the same time, a priority
scheme could be used to determine the order in which the interrupts would be serviced.
Discuss what issues need to be considered in assigning priorities to different interrupts.
A number of issues need to be considered in order to determine the priority scheme. Interrupts
raised by devices should be given higher priority than traps generated by the user program; a
device interrupt can therefore interrupt code used for handling system calls.

34
Compiled by S.O.M.M. Kasinge

Second, interrupts that control devices might be given higher priority than interrupts that simply
perform tasks such as copying data served up a device to user/kernel buffers, since such tasks
can always be delayed.
Third, devices that have realtime constraints on when its data is handled should be given higher
priority than other devices. Also, devices that do not have any form of buffering for its data would
have to be assigned higher priority since the data could be available only for a short period of
time.

Briefly define the seven RAID levels.


RAID (redundant array of independent disks) is viewed by the OS as a single logical drive.
Level 0 - Striping is non-redundant, data transfer capacity is very high.
Level 1 - Every disk in the array has a mirror disk that contains the same data. Data transfer
capacity is higher than single disk for read; similar to single disk for write.
Level 2&3 - Parallel access (level 2 is redundant via Hamming code, while level 3 is bit-interleaved
parity), data transfer capacity is the highest of all listed alternatives.
Level 4, 5, & 6 - Independent access (level 4 is block-interleaved parity, level 5 is block-interleaved
distributed parity, level 6 is block-interleaved dual distributed parity), dtc are a similar to Striping
for read, lower than single disk for write (in the order from best to worst of 5, 6, 4).

FILE MANAGEMENT
What is the difference between a field and a record?
A field is the basic element of data. An individual field contains a single value, such as a last name.
A record is a collection of related fields that can be treated as a unit by some application program.

What is the difference between a file and a database?


A file is a collection of similar records. The file is treated as a single entity by users and
applications and may be referenced by name.
A database is a collection of related data. Explicit relationships exist among elements of data It
consists of one or more types of files.

What is a file management system?


Is the set of system software that provides service to user and applications in the use of files.

35
Compiled by S.O.M.M. Kasinge

What criteria are important in choosing a file organization?


 Short access time.
 Ease of update.
 Economy of storage.
 Simple maintenance.
 Reliability.

List and briefly define five file organizations.


 The pile - least-complicated form. Data is collected in the order it arrives. Each record consists
of one burst of data. Purpose is to accumulate a mass of data and save it.
 The sequential file - most common form. A fixed format is used for records. All records are
of same length. All records are of the same length, consisting of the same number of fixed-
length fields in a particular order
 The indexed sequential file - popular approach to overcoming the disadvantages of the
sequential file. Records are organized in sequence based on a key field, just like sequential
file. An index to the file to support random access and an overflow file are added.
 The indexed file - Records are accessed only through their indexes. No restriction on the
placement of records as long as a pointer in at least one index refers to that record. All records
are of the same length, consisting of the same number of fixed-length fields in a particular
order.
 The direct or hashed file - exploits the capability found on disks to access directly any block
of a known address. As with sequential and indexed sequential files, a key field is required in
each record.

Why is the average search time to find a record in a file less for an indexed sequential file than
for a sequential file?
The index provides a lookup capability to reach quickly the vicinity of a desired record, something
the sequential file does not have.

What are typical operations that may be performed on a directory?


 Search.
 Create file.
 Delete file.
 List directory.
 Update directory.

36
Compiled by S.O.M.M. Kasinge

What is the relationship between a pathname and a working directory?


The working directory enables files to be referenced relative to it, so that the entire pathname
does not have to be spelled out each time you try to access a particular file.

What are typical access rights that may be granted or denied to a particular user for a particular
file?
 None: User may not even know of the files existence
 Knowledge: User can only determine that the file exists and who its owner is
 Execution: The user can load and execute a program but cannot copy it.
 Reading: The user can read the file for any purpose, including copying and execution.
 Appending: The user can add data to the file but cannot modify or delete any of the file’s
contents
 Updating: The user can modify, delete, and add to the file’s data.
 Changing protection: User can change access rights granted to other users
 Deletion: User can delete the file.

List and briefly define three blocking methods.


Records are the logical unit of access of a structured file,
Whereas blocks are the unit of I/O with secondary storage. For I/O to be performed, records
must be organized as blocks.
 Fixed blocking - fixed-length records are used, and an integral number of records are stored
in a block. There may be unused space at the end of each block (internal fragmentation)
 Variable-length spanned blocking - variable-length records are used and are packed into
block with no unused space. Some records must span two blocks, with the continuation
indicated by a pointer to the successor block.
 Variable-length unspanned blocking - variable-length records are used, but spanning is not
employed. There is wasted space in most blocks because of the inability to use the remainder
of a block if the next record is larger than the remaining space.

List and briefly define three file allocation methods.


 Contiguous allocation - A single contiguous set of blocks is allocated to a file at the time of
file creation. This is a preallocation strategy, using variable size portions.
 Chained allocation - total opposite of contiguous allocation. Allocation is on an individual
block basis. Each block contains a pointer to the next block in the chain. Preallocation is
possible, but it is more common to simply allocate blocks as needed.
 Indexed allocation - addresses many of the problems of contiguous and chained allocation.
The file allocation table contains a separate one-level index for each file; the index has one

37
Compiled by S.O.M.M. Kasinge

entry for each portion allocated to the file. Allocation is on the basis of either fixed-size blocks
or variable-size portions.

EMBEDDED OPERATING SYSTEMS

What is an embedded system?


A combination of computer hardware and software, and perhaps additional mechanical or other
parts, designed to perform a dedicated function. In many cases, embedded systems are part of a
larger system or product, as in the case of an antilock braking system in a car.” They are tightly
coupled to their environment.

What are some typical requirements for or constraints on embedded systems?


Often, embedded systems are tightly coupled to their environment.
This can give rise to real-time constraints imposed by the need to interact with the environment.
Constraints, such as
required speeds of motion,
required precision of measurement,
required time durations, dictate the timing of software operations.

What are some of the key characteristics of an embedded OS?


 Real-time operation
 Reactive operation
 Configurability
 I/O device flexibility
 Streamlined protection mechanisms
 Direct use of interrupts

Explain the relative advantages and disadvantages of an embedded OS based on existing


commercial OS compared to a purpose-built embedded OS.
**The answer is coming soon.

38
Compiled by S.O.M.M. Kasinge

COMPUTER SECURITY

Define computer security


The protection afforded to an automated information system in order to attain the applicable
objectives of preserving the integrity, availability, and confidentiality of information system
resources (including hardware, software, firmware, data, and telecommunications).

What are the fundamental requirements addressed by computer security?


Confidentiality - Preserving authorized restriction on information access and disclosure,
including means for protecting personal privacy and proprietary information.
Integrity - Guarding against improper information modification or destruction, including ensuring
information non-repudiation and authenticity.
Availability - Assures that systems work promptly and service is not denied to authorized users.
Ensuring timely and reliable access to and use of information.

What is the difference between passive and active security threats?


Passive attacks - A passive attack attempts to learn or make use of information from the system
but does not affect system resources. They are in the nature of eavesdropping on, or monitoring
of, transmissions. The goal is to obtain information that is being transmitted.
Active attacks - An active attack attempts to alter system resources or affect their operation. It
involves some modification of the data stream or the creation of a false stream.
Whereas passive attacks are difficult to detect, measures are available to prevent their success.
On the other hand, it is very difficult to prevent active attacks absolutely, because to do so would
require physical protection of all communications facilities and paths at all times. Instead, the
goal is to detect them and to recover from any disruption or delays caused by them.

List and briefly define three classes of intruders.


 Masquerader - Someone not authorized to use the computer and who penetrates a system's
access controls to exploit an actual user's account.
 Misfeasor - A legitimate user who accesses data, programs, or resources for which such
access is not authorized, or who is authorized for such access but misuses their privileges.
 Clandestine user - Someone who seizes supervisory control of the system and uses this
control to evade auditing and access controls or to suppress audit collection.

39
Compiled by S.O.M.M. Kasinge

List and briefly define three intruder behavior patterns.


Hackers - find vulnerable targets and attack them.
Criminals - organized group of hackers who have specific targets, or at least classes of targets in
mind (as opposed to just vulnerable targets).
Insider attacks - very hard to detect and prevent. Employees have access and knowledge of
databases, and can obtain information, and use that information, in an inappropriate manner.

What is the role of compression in the operation of a virus?


It makes the infected version as long as the uninfected version of an executable file, so it is harder
to detect if a file contains a virus.

What is the role of encryption in the operation of a virus?


It makes it more difficult to detect a pattern, because the bulk of each copy of a virus has its own
unique encryption key.
The mutation engine creates a random encryption key to encrypt the remainder of the virus.
The key is stored with the virus, and the mutation engine itself is altered. When the virus
replicates, a different random key is selected. Because the bulk of the virus is encrypted with a
different key for each instance, there is no consistent bit pattern to observe.

What are the typical phases of operation of a virus or worm?


 Dormant phase: The virus is idle, it will eventually be activated by some event, such as a date
or another program.
 Propagation phase: The virus places a copy of itself into other programs or into certain
system areas on the disk.
 Triggering phase: The virus is activated to perform the function for which it was intended. As
with the dormant phase, the triggering phase can be caused by a variety of system events.
 Execution phase: The function is performed. The function may be harmless, such as a
message on the screen, or damaging, such as the destruction of programs and data files.

In general terms, how does a worm propagate?


Search for other systems to infect by examining host tables or similar repositories of remote
system addresses, establish a connection with a remote system, and copy itself to the remote
system and cause the copy to be run.

40
Compiled by S.O.M.M. Kasinge

What is the difference between a bot and a rootkit?


A Bot is a program that secretly takes over another Internet-attached computer and then uses
that computer to launch attacks that are difficult to trace to the bot's creator.
A Rootkit is a set of programs installed on a system to maintain administrator access to the
system. It alters the host's standard functionality in a malicious and stealthy way. Rootkits do not
directly rely on vulnerabilities to get on a computer.

In general terms, what are four means of authenticating user's identity?


Something the individual knows eg: password, PIN
Something the individual possesses eg: Card, RFID badge
Something the individual is (static biometrics)
Something the individual does (dynamic biometrics)

Explain the difference between a simple memory card and a smart card.
Memory cards can only store store but not process data. Smart cards can process data and store
it, they contain an entire microprocessor, including processor, memory, and I/O ports.

List and briefly describe the principle physical characteristics used for biometric identification.
Facial: Define characteristics based on relative location and shape of key facial features, such as
eyes
Fingerprints: A fingerprint is the pattern of ridges and furrows on the surface of the fingertip.
Fingerprints are believed to be unique across the entire human population.
Hand geometry: Hand geometry systems identify features of the hand, including shape, and
lengths and widths of fingers.
Retinal pattern: The pattern formed by veins beneath the retinal surface is unique and therefore
suitable for identification.
Iris structure: Another unique physical characteristic is the detailed structure of the iris
Signature: Each individual has a unique style of handwriting, and this is reflected especially in the
signature, which is typically a frequently written sequence.
Voice: voice patterns are more closely tied to the physical and anatomical characteristics of the
speaker

Briefly describe the difference between DAC and RBAC.


DAC (Discretionary access control) systems define the access rights of individual users and
groups of users. RBAC (Discretionary access control) is based on the roles that users assume in
a system rather than the user's identity. Users are assigned to roles in an RBAC system.

41
Compiled by S.O.M.M. Kasinge

Explain the difference between anomaly intrusion detection and signature intrusion detection.
Anomaly approach attempts to define normal behaviors, while signature attempts to define
proper behavior.

What are the main differences between capability lists and access lists?
An access list is a list for each object consisting of the domains with a nonempty set of access
rights for that object. A capability list is a list of objects and the operations allowed on those
objects for each domain.

What is a digital immune system?


A comprehensive approach to virus protection whose goal is to provide rapid response to viruses
and remove them as soon as possible.

How does behavior-blocking software work?


It integrates with the OS of a host computer and monitors program behavior in real time for
malicious actions.

Describe some worm countermeasures.


Signature-based worm scan filters: This approach generates a worm signature, which is then
used to prevent worm scans from entering/leaving a network/host
Filter-based worm containment: The filter checks a message to determine if it contains worm
code
Payload-classification-based worm containment: These network-based techniques examine
packets to see if they contain a worm
Threshold random walk (TRW) scan detection: TRW exploits randomness in picking destinations
to connect to as a way of detecting if a scanner is in operation
Rate limiting: This class limits the rate of scanlike traffic from an infected host.
Rate halting: This approach immediately blocks outgoing traffic when a threshold is exceeded
either in outgoing connection rate or diversity of connection attempts

What is the purpose of using a “salt” along with the user-provided password? Where should
the “salt” be stored, and how should it be used?
When a user creates a password, the system generates a random number (which is the salt) and
appends it to the user-provided password, encrypts the resulting string and stores the encrypted
result and the salt in the password file. When a password check is to be made, the password

42
Compiled by S.O.M.M. Kasinge

presented by the user is first concatenated with the salt and then encrypted before checking for
equality with the stored password. Since the salt is different for different users, a password
cracker cannot check a single candidate password, encrypt it, and check it against all of the
encrypted passwords simultaneously.

What types of programming languages are vulnerable to buffer overflows?


Ones that do not include code that enforces range checks automatically, for example assembly
languages and C and its derivatives.

What are the two broad categories of defenses against buffer overflows?
Compile-time defenses - harden programs to resist attacks in new programs.
Run time defenses - detect and abort attacks in existing programs.

CLIENT-SERVER COMPUTING

What is client/server computing?


A set of clients and servers. The client stations present a graphical interface that is comfortable
to users, while the server provides a set of shared services to clients.

What distinguishes client/server computing from any other form of distributed data
processing?
 User has control over timing and style of computer usage
 Emphasis on centralizing corporate databases and many network management and utility
functions
 Commitment to open and modular systems
 Networking is fundamental to the operation

What is the role of a communications architecture such as TCP/IP in a client/server


environment?
It enables clients and servers to share the same communications protocols and support the same
applications.

43
Compiled by S.O.M.M. Kasinge

Discuss the rationale for locating applications on the client, the server, or split between client
and server.
You want to optimize the use of resources. Different cases, depending on application needs, the
bulk of application software executes at the server, while in other cases, it executes at the client.

What are fat clients and thin clients, and what are the differences in philosophy of the two
approaches?
Fat client - considerable fraction of the load is on the client. It takes advantage of desktop power,
offloading application processing from servers and making them more efficient and less likely to
bottleneck.
Thin client - much smaller load of work is on the client, mimics the traditional host-centered
approach.

Suggest pros and cons for fat client and thin client strategies.
**Answer will come soon

Explain the rationale behind the three-tier client/server architecture.


The application software is distributed among three types of machines: a user machine, a middle-
tier server, and a backend server

What is middleware?
Is a set of tools (standard API and protocols) that provide a uniform means and style of access to
system resources across all platforms. Middleware makes it easy to implement the same
application on a variety of server types and workstation types.

Because we have standards such as TCP/IP, why is middleware needed?


There are many different versions of TCP/IP, middleware allows you to operate over any TCP/IP
implementation.

List some benefits and disadvantages of blocking and nonblocking primitives for message
passing.
Blocking - Pro: assures the receiver is ready and waiting for the message.
Con: takes longer than non-blocking.

44
Compiled by S.O.M.M. Kasinge

Non-blocking - Pro: automatically sends message to the receiver when the sender is ready to
send.
Con: the receiver may not be ready for the message being passed, and thus some
of the information may not be picked up by the receiver.

List and briefly define four different clustering methods.


Absolute scalability - cluster can have dozens or even hundreds of machines, each of which is a
multiprocessor.
Incremental scalability - A cluster is configured in such a way that it is possible to add new
systems to the cluster in small increments.
High availability - Because each node in a cluster is a standalone computer, the failure of one
node does not mean loss of service.
Superior price/performance - By using commodity building blocks, it is possible to put together
a cluster with equal or greater computing power than a single large machine, at much lower cost.

45

You might also like