Exercises & LAB 1: Exercises - Silberschatz 9'th Edition, Operating Systems Concepts
Exercises & LAB 1: Exercises - Silberschatz 9'th Edition, Operating Systems Concepts
Ex2: What is the main difficulty that a programmer must overcome in writing an operating
system for a real-time environment?
Answer:
The main difficulty is keeping the operating system within the fixed time constraints of a real-
time system. If the system does not complete a task in a certain time frame, it may cause a
breakdown of the entire system it is running. Therefore when writing an operating system for a
real-time system, the writer must be sure that his scheduling schemes don’t allow response time
to exceed the time constraint.
Ex3: How does the distinction between kernel mode and user-mode function as a rudimentary
form of protection (security) system?
Answer:
The distinction between kernel mode and user mode provides a rudimentary form of protection
in the following manner. Certain instructions could be executed only when the CPU is in kernel
mode. Similarly, hardware devices could be accessed only when the program is executing in
kernel mode. Control over when interrupts could be enabled or disabled is also possible only
when the CPU is in kernel mode. Consequently, the CPU has very limited capability when
executing in user mode, thereby enforcing protection of critical resources.
Ex5: Distinguish between the client–server and peer-to-peer models of distributed systems.
Answer:
The client-server model firmly distinguishes the roles of the client and server. Under this model,
the client requests services that are provided by the server. The peer-to-peer model doesn’t have
such strict roles. In fact, all nodes in the system are considered peers and thus may act as either
clients or servers—or both. A node may request a service from another peer, or the node may in
fact provide such a service to other peers in the system.
Ex7:What are the five major activities of an operating system with regard to
process management?
Answer:
The five major activities are:
a. The creation and deletion of both user and system processes
b. The suspension and resumption of processes
c. The provision of mechanisms for process synchronization
d. The provision of mechanisms for process communication
e. The provision of mechanisms for deadlock handling
Ex8: What are the three major activities of an operating system with regard to memory
management?
Answer:
The three major activities are:
a. Keep track of which parts ofmemory are currently being used and by whom.
b. Decide which processes are to be loaded into memory when memory space becomes available.
c. Allocate and deallocate memory space as needed.
Ex9: What are the three major activities of an operating system with regard to secondary-storage
management?
Answer:
The three major activities are:
• Free-space management.
• Storage allocation.
• Disk scheduling.
Ex10:What is the purpose of the command interpreter? Why is it usually separate from the
kernel?
Answer:
It reads commands fromthe user or fromafile ofcommands and executes them, usually by turning
them into one or more system calls. It is usually not part of the kernel since the command
interpreter is subject to changes.
Ex12: What is the main advantage of the layered approach to system design? What are the
disadvantages of using the layered approach?
Answer:
As in all cases of modular design, designing an operating system in a modular way has several
advantages. The system is easier to debug and modify because changes affect only limited
sections of the system rather than touching all sections of the operating system. Information
is kept only where it is needed and is accessible only within a defined and restricted area, so any
bugs affecting that data must be limited to a specific module or layer.
Ex13: Why do some systems store the operating system in firmware, while others store it on
disk?
Answer:
For certain devices, such as handheld PDAs and cellular telephones, a disk with a file system
may be not be available for the device. In this situation, the operating system must be stored in
firmware.
Lab in Linux
Some common form of suffix
.sh—A Bash shell script
n .txt—A generic text file
n .log—A log file
n .html—A HTML Web page
n .tgz (or .tar.gz)—Compressed file archive
What`s a root directory?
A pathname is a string that identifies the location of a particular file, the sequences of
directories to move through to find it.
Most Linux distributions include the following directories:
n /dev—Contains device drivers
n /bin and /usr/bin—Contains standard Linux commands
n /lib and /usr/lib—Contains standard Linux libraries
n /var—Contains configuration and log files
n /etc—Contains default configuration files
n /usr/local/bin—Contains commands not a part of the distribution, added by your administrator
n /opt—Contains commercial software
n /tmp—Stores temporary files
n /sbin and /usr/sbin—Contains system administration commands (/sbin stands for “safe” bin)
The common kind of non regular file is a device file. Keeping with the file-oriented
design of Linux, devices are represented by files. Device files allow direct
communication to a particular device attached to a computer. There are actually two
kinds of device files, but shell rogrammers are mainly interested in the type called
character device files. All devices files are located in the /dev directory.
Homework:
Exercises: Tanenbaum, 4`rth edition, MOS
Ex1: What are the two main functions of an operating system?
Ex2: What is the difference between timesharing and multiprogramming systems?
Ex3: Which of the following instructions should be allowed only in kernel mode?
(a) Disable all interrupts.
(b) Read the time-of-day clock.
(c) Set the time-of-day clock.
(d) Change the memory map.
Ex4: Consider a system that has two CPUs, each CPU having two threads (hyper-threading).
Suppose three programs, P0, P1, and P2, are started with run times of 5, 10 and 20 msec,
respectively. How long will it take to complete the execution of these programs? Assume that all
three programs are 100% CPU bound, do not block during execution, and do not change CPUs
once assigned
Ex5: Consider a computer system that has cache memory, main memory (RAM) and disk, and an
operating system that uses virtual memory. It takes 1 nsec to access a word from the cache, 10
nsec to access a word from the RAM, and 10 ms to access a word from the disk. If the cache hit
rate is 95% and main memory hit rate (after a cache miss) is 99%, what is the average time to
access a word?
Ex6: A file whose file descriptor is fd contains the following sequence of bytes: 3, 1, 4, 1, 5,
9, 2, 6, 5, 3, 5. The following system calls are made:
lseek(fd, 3, SEEK SET);
read(fd, &buffer, 4);
where the lseek call makes a seek to byte 3 of the file. What does buffer contain after the read
has completed?
Ex7: What is the essential difference between a block special file and a character special file?
Ex8: Explain how separation of policy and mechanism aids in building microkernel-based
operating systems.
Lab:
References: Linux Shell Scripting with BASH – Chapter 2 and Chapter 3; Linux Shell Scripting
Tutorials – Pages 1-8; Linux Bible – Part 1 (Page 1-120); The linux Complete References – Part
1 (Page 3-33); Ubuntu Linux the Complete References – Part 1 (Pages 3-66), Ubuntu Server
Guide – Chap1-3; Ubuntu Desktop (Page 1-82)
(See on Microsoft Team Platform: OS-2018 > Exercises & Lab > Lab 1.