0% found this document useful (0 votes)
275 views

Exercises & LAB 1: Exercises - Silberschatz 9'th Edition, Operating Systems Concepts

The document provides exercises and a lab related to operating systems concepts from textbooks by Silberschatz and Tanenbaum. The exercises cover topics like the main purposes of an OS, challenges in real-time systems, kernel vs user mode, system calls, process and memory management, and distributed systems models. The lab section describes common Linux file extensions, directories, device files, and basic commands. It lists several Linux textbooks and pages as references for the homework assignments.

Uploaded by

TediElmas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
275 views

Exercises & LAB 1: Exercises - Silberschatz 9'th Edition, Operating Systems Concepts

The document provides exercises and a lab related to operating systems concepts from textbooks by Silberschatz and Tanenbaum. The exercises cover topics like the main purposes of an OS, challenges in real-time systems, kernel vs user mode, system calls, process and memory management, and distributed systems models. The lab section describes common Linux file extensions, directories, device files, and basic commands. It lists several Linux textbooks and pages as references for the homework assignments.

Uploaded by

TediElmas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Exercises & LAB 1

Exercises – Silberschatz 9`th edition, Operating Systems Concepts


Ex1:What are the three main purposes of an operating system?
Answer:
The three main purposes are:
• To provide an environment for a computer user to execute programs on computer hardware in a
convenient and efficient manner.
• To allocate the separate resources of the computer as needed to solve the problem given. The
allocation process should be as fair and efficient as possible.
• As a control program it serves two major functions: (1) supervision of the execution of user
programs to prevent errors and improper use of the computer, and (2) management of the
operation and control of I/O devices.

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.

Ex4: Which of the following instructions should be privileged?


a. Set value of timer.
b. Read the clock.
c. Clear memory.
d. Issue a trap instruction.
e. Turn off interrupts.
f. Modify entries in device-status table.
g. Switch from user to kernel mode.
h. Access I/O device.
Answer:
The following operations need to be privileged: Set value of timer, clear memory, turn off
interrupts,modify entries in device-status table, access I/O device. The rest can be performed in
user mode.

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.

Ex6:What is the purpose of system calls?


Answer:
System calls allow user-level processes to request services of the operating 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.

Ex11: What is the purpose of system programs?


Answer:
System programs can be thought of as bundles of useful system calls. They provide basic
functionality to users so that users do not need to write their own programs to solve common
problems.

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.

 Common device files include:


/dev/tty—The terminal window (or console) your program is running under
n /dev/dsp—The interface that plays AU sound files on your sound card
n /dev/fd0—The first floppy drive
n /dev/hda1—The first IDE drive partition
n /dev/sda1—The first SCSI drive partition
 Some basic commands in linux:
References: https://www-uxsup.csx.cam.ac.uk/pub/doc/suse/suse9.0/userguide-9.0/ch24s04.html

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.

You might also like