You are on page 1of 5

Alexandria University

Faculty of Engineering
Computer and Systems Engineering
Fall 2014

Homework 1
CS333: Operating Systems
Assigned: October 18, 2014
Due: October 29, 2014

Homework 1: Computer System Overview, Operating


System Overview
1. Define the 2 main categories of processor registers and the purpose for each of them.

Solution:
User visible registers: available to OS and user programs. used to hold data, addresses,
conditions.
Control and status registers: available to OS and not user programs. used to control
the processor operation or by the OS to manage process execution. Example: PC.

2. What is an interrupt? How are multiple interrupts dealt with?

Solution: Interrupts is a mechanism by which other modules (I/O, memory) may interrupt
the normal sequencing of the processor.
The two approaches to deal with interrupts are as follows:
Disabling interrupts while an interrupt is being processed. A disabled interrupt simply means that the processor ignores any new interrupt request signal. If an interrupt
occurs during this time, it generally remains pending and will be checked by the processor after the processor has reenabled interrupts.
Define priorities for interrupts and to allow an interrupt of higher priority to cause a
lower-priority interrupt handler to be interrupted.

3. What are the three main purposes of an operating system?

Solution:
Convenience: An OS makes a computer more convenient to use.
Efficiency: An OS allows the computer system resources to be used in an efficient manner.
Ability to evolve: An OS should be constructed in such a way as to permit the effective
development, testing, and introduction of new system functions with- out interfering
with service.

1 of 5

4. In a multiprogramming and time-sharing environment, several users share the system simultaneously. List two security problems that can occur in these environments.

Solution:
Confidentiality: Assures that users cannot read data for which access is unauthorized.
For example, reading (stealing) other process data or files.
Data integrity: Protection of data from unauthorized modification. For example, a process should not modify the code for another process.

5. Define the essential properties of the following types of operating systems:


Batch
Interactive
Time-sharing
Distributed
Real-time

Solution:
Batch. Jobs are are grouped (batched) together sequentially and submitted to the computer. Each program is constructed to branch back to the monitor (operating system)
when it completes processing, at which point the monitor automatically begins loading
the next program. Utilization of the processor is expected to improve.
Interactive. User input is required to complete these jobs. The requirement for an interactive computing facility can be, and often is, met by the use of a dedicated personal
computer or workstation.
Time-sharing. At regular time intervals, the current user (process/job) would be preempted and another user (process/job) loaded in.
Distributed. Multiple independent machines (shared nothing) cooperate to finish a
computation.
Real-time. A fast response time (or within a prespecified short time interval) is required
for user queries.

2 of 5

6. What is the difference between a multiprocessor and a multicore system?


Solution: A multicore system combines two or more processors (called cores) on a single
piece of silicon (called a die).
7. Consider the following code:
for (i = 0; i < 20; i++)
for (j = 0; j < 10; j++)
a[i] = a[i] * j
(a) Give one example of the spatial locality in the code.
(b) Give one example of the temporal locality in the code.
Solution:
Accessing the array elements in turn by the outer loop is an example for spatial locality.
Referencing each element a[i] in the statement a[i] = a[i] * j in the inner loop
is an example of temporal locality.
8. Suppose a stack is to be used by the processor to manage procedure calls and returns. Can the
program counter be eliminated by using the top of the stack as a program counter?
Solution: Yes, if the stack is only used to hold the return address.
9. A computer has a cache, main memory, and a disk used for virtual memory. 20 ns are required
to reference a word that is in the cache. If the word is in main memory but not in the cache, 70
ns are needed to load it into the cache (this includes the time to originally check the cache), and
then the reference is started again. If the word is not in main memory, 15 ms are required to fetch
the word from disk, followed by 70 ns to copy it to the cache, and then the reference is started
again. The cache hit ratio is 0.7 and the main memory hit ratio is 0.5. What is the average time in
ns required to access a referenced word on this system?
Solution:
time required in case of cache hit = 20 ns
time required in case of cache miss, memory hit = 70 ns + 20 ns = 90 ns
time required in case of cache miss, memory miss = 15 ms + 70 ns + 20 ns = 15000090 ns
average time = 0.7 * 20 + 0.3 [0.5*90 + 0.5*15000090]= 2250041 ns

3 of 5

10. Explain the distinction between a real address and a virtual address.

Solution: A real address is the physical or actual address of a memory location. Virtual
memory is a facility that allows programs to address memory from a logical point of view,
without regard to the amount of main memory physically available. Therefore, a virtual
address is a logical address that needs to be mapped to a physical address.

11. Describe the round-robin scheduling technique.

Solution: Processes that are ready for execution will be given equal time on the processor in
turn.
12. Explain the difference between a monolithic kernel and a microkernel.

Solution: In a monolithic kernel, most of the OS functionality is provided in one large kernel
(one process with all its functions sharing the same address space). The OS functionality include scheduling, file system, networking, device drivers, memory management, and more.
A microkernel architecture assigns only a few essential functions to the kernel, including address spaces, interprocess communication (IPC), and basic scheduling. Other OS services are
provided by processes.

13. Which of the following instructions should be privileged?


(a) Set value of timer.
(b) Read the clock.
(c) Clear memory.
(d) Turn off interrupts.
(e) Switch from user to kernel mode.
(f) Access I/O device.

Solution:
Privileged instructions: Set value of timer, Clear memory, Turn off interrupts, Switch
from user to kernel mode, Access I/O device.
Non privileged instructions: Read the clock.

4 of 5

14. 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 and yet does not permanently deny processor
time to processor-bound programs.

Solution: A typical trace of an I/O bound program will show execution of few instructions
and then a long waiting for I/O devices. The described scheduling algorithm will favor
I/O bound programs because they use the processor less and therefore they will be chosen
first. However, since the blocking time is long, most of the I/O bound programs can all be
in the blocked state, and hence a chance is given for processor-bound programs to seize the
processor.

15. What is the purpose of system calls, and how do system calls relate to the OS and to the concept
of dual-mode (kernel-mode and user-mode) operation?

Solution: The system call is the means by which a process requests a specific kernel service.
A process runs in user mode, if an operation is privileged, a system call is made, and a switch
to kernel (system) mode is made.

5 of 5