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

Assignment Key (Chapter-2)

Uploaded by

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

Assignment Key (Chapter-2)

Uploaded by

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

Assignment Key

Unit-1(Chapter-2)
Operating System-Services

Q1. Explain Services provided by operating Systems?

Answer:
1. Program execution
2. I/O operations
3. File system manipulation
4. Communication
5. Error detection
6. Resource allocation
7. Accounting
Following are the services provided by an operating system for the convenience of users:
1. Program Execution
The purpose of computer system is to allow the users to execute programs in an efficient manner.
The operating system provides an environment where the user can conveniently run these
programs. The user does not have to worry about the memory allocation or de-allocation or any
other thing because these things are taken care of by the operating system.
To run a program, the program is required to be loaded into the RAM first and then to
assign CPU time for its execution. Operating system performs this function for the convenience
of the user. It also performs other important tasks like allocation and de-allocation of memory,
CPU scheduling etc.
2. I/O Operations
Each program requires an input and after processing the input submitted by user it produces
output. This involves the use of I/O devices. The operating system hides the user from all these
details of underlying hardware for the I/O. So the operating system makes the users convenient
to run programs by providing I/O functions. The I/O service cannot be provided by user-level
programs and it must be provided by the operating system.
3. File System Manipulation
While working on the computer, generally a user is required to manipulate various types of files
like as opening a file, saving a file and deleting a file from the storage disk. This is an important
task that is also performed by the operating system.
Thus operating system makes it easier for the user programs to accomplish their task by
providing the file system manipulation service. This service is performed by the 'Secondary
Storage Management' a part of the operating system.
4. Communication
Operating system performs the communication among various types of processes in the form of
shared memory. In multitasking environment, the processes need to communicate with each
other and to exchange their information. These processes are created under a hierarchical
structure where the main process is known as parent process and the sub processes are known as
child processes.
5. Error Detection
Operating system also deals with hardware problems. To avoid hardware problems the operating
system constantly monitors the system for detecting the errors and fixing these errors (if found).
The main function of operating system is to detect the errors like bad sectors on hard disk,
memory overflow and errors related to I/O devices. After detecting the errors, operating system
takes an appropriate action for consistent computing.
This service of error detection and error correction cannot be handled by user programs because
it involves monitoring the entire computing process. These tasks are too critical to be handed
over to the user programs. A user program, if given these privileges; can interfere with the
corresponding operation of the operating systems.
6. Resource allocation
In the multitasking environment, when multiple jobs are running at a time, it is the responsibility
of an operating system to allocate the required resources (like as CPU, main memory, tape drive
or secondary storage etc.) to each process for its better utilization. For this purpose various types
of algorithms are implemented such as process scheduling, CPU scheduling, disk scheduling etc.
7. Accounting
Operating system keeps an account of all the resources accessed by each process or user. In
multitasking, accounting enhances the system performance with the allocation of resources to
each process ensuring the satisfaction to each process.
8. Protection System
If a computer system has multiple users and allows the concurrent execution of multiple
processes, then the various processes must be protected from one another's activities.

Q2. The services and functions provided by an operating system can be divided into two main
categories. Briefly describe the two categories and discuss how they differ.

Answer: One class of services provided by an operating system is to enforce protection between
different processes running concurrently in the system. Processes are allowed to access only
those memory locations that are associated with their address spaces. Also, processes are not
allowed to corrupt files associated with other users. A process is also not allowed to access
devices directly without operating system intervention. The second class of services provided by
an operating system is to provide new functionality that is not supported directly by the
underlying hardware. Virtual memory and file systems are two such examples of new services
provided by an operating system.
User Operating-System Interface

Q1. Differentiate between Complier and Interpreter?

Answer: An interpreter reads one instruction at a time and carries out the actions implied by
that Instruction. It does not perform any translation. But a compiler translates the entire
instructions.

Q2. What is the purpose of the command interpreter? Why is it usually separate from the kernel?
Would it be possible for the user to develop a new command interpreter using the system-call
interface provided by the operating system?

Answer: 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
the command interpreter is subject to changes. An user should be able to develop a new
command interpreter using the system-call interface provided by the operating system. The
command interpreter allows an user to create and manage processes and also determine ways by
which they communicate (such as through pipes and files). As all of this functionality could be
accessed.

System calls

Q1. Write short notes on System calls?[2016]

Answer: System calls provide the interface between a process and the operating system. System
calls for modern Microsoft windows platforms are part of the win32 API, which is available for
all the compilers written for Microsoft windows.

Q2. What system calls have to be executed by a command interpreter or shell in order to start a
new process?

Answer: In UNIX systems, a fork system call followed by an exec system call need to be
performed to start a new process. The fork call clones the currently executing process, while the
exec call overlays a new process based on a different executable over the calling process.

Types of System calls

Q1. What is a System call? Explain the various types of system calls provided by an operating
system.
Answer: System calls provide an interface between the process and the operating system.

 System calls allow user-level processes to request some services from the operating
system which process itself is not allowed to do.

 In handling the trap, the operating system will enter in the kernel mode, where it has
access to privileged instructions, and can perform the desired service on the behalf of
user-level process.

 It is because of the critical nature of operations that the operating system itself does them
every time they are needed.

 For example, for I/O a process involves a system call telling the operating system to read
or write particular area and this request is satisfied by the operating system.

Types of System calls

 Process control

 File management

 Device management

 Information maintenance

 Communications

1) Process Control:
 A running program needs to be able to stop execution either normally or abnormally.

 When execution is stopped abnormally, often a dump of memory is taken and can be
examined with a debugger.

 Following are functions of process control:

i. end, abort

ii. load, execute

iii. create process, terminate process

iv. get process attributes, set process attributes

v. wait for time

vi. wait event, signal event

vii. allocate and free memory

2) File management :

 We first need to be able to create and delete files. Either system call requires the name of
the file and perhaps some of the file's attributes.

 Once the file is created, we need to open it and to use it. We may also read, write, or
reposition. Finally, we need to close the file, indicating that we are no longer using it.

 We may need these same sets of operations for directories if we have a directory structure
for organizing files in the file system.

 In addition, for either files or directories, we need to be able to determine the values of
various attributes and perhaps to reset them if necessary. File attributes include the file
name, a file type, protection codes, accounting information, and so on

Functions:

o create file, delete file

o open, close file

o read, write, reposition


o get and set file attributes

3) Device Management:

 A process may need several resources to execute - main memory, disk drives, access to
files, and so on. If the resources are available, they can be granted, and control can be
returned to the user process. Otherwise, the process will have to wait until sufficient
resources are available.

 The various resources controlled by the OS can be thought of as devices. Some of these
devices are physical devices (for example, tapes), while others can be thought of as
abstract or virtual devices (for example, files).

 Once the device has been requested (and allocated to us), we can read, write, and
(possibly) reposition the device, just as we can with files.

 In fact, the similarity between I/O devices and files is so great that many OSs, including
UNIX, merge the two into a combined file-device structure.

 A set of system calls is used on files and devices. Sometimes, 1/0 devices are identified
by special file names, directory placement, or file attributes.

Functions:

o request device, release device

o read, write, reposition

o get device attributes, set device attributes

o logically attach or detach devices

4) Information Maintenance

 Many system calls exist simply for the purpose of transferring information between the
user program and the OS. For example, most systems have a system call to return the
current time and date.

 Other system calls may return information about the system, such as the number of
current users, the version number of the OS, the amount of free memory or disk space,
and so on.
 In addition, the OS keeps information about all its processes, and system calls are used to
access this information. Generally, calls are also used to reset the process information.

Functions:

 get time or date, set time or date

 get system data, set system data

 get and set process, file, or device attributes

5) Communication

 There are two common models of interprocess communication: the message-passing


model and the shared-memory model. In the message-passing model, the communicating
processes exchange messages with one another to transfer information.

 In the shared-memory model, processes use shared memory creates and shared memory
attaches system calls to create and gain access to regions of memory owned by other
processes.

 Recall that, normally, the OS tries to prevent one process from accessing another
process's memory. Shared memory requires that two or more processes agree to remove
this restriction. They can then exchange information by reading and writing data in the
shared areas.

 Message passing is useful for exchanging smaller amounts of data, because no conflicts
need be avoided. It is also easier to implement than is shared memory for intercomputer
communication.

 Shared memory allows maximum speed and convenience of communication, since it can
be done at memory speeds when it takes place within a computer. Problems exist,
however, in the areas of protection and synchronization between the processes sharing
memory.

Functions:

o create, delete communication connection

o send, receive messages


o transfer status information

o Attach and Detach remote devices

Q2. What are the five major activities of an operating system in regard to file management?

Answer:

o The creation and deletion of files


o The creation and deletion of directories
o The support of primitives for manipulating files and directories
o The mapping of files onto secondary storage

o The backup of files on stable (nonvolatile) storage media

Q3. What are the three major activities of an operating system in regard to secondary-storage
management?
Answer:
 Free-space management.
 Storage allocation.
 Disk scheduling.

Q4.What is the purpose of the command interpreter? Why is it usually separate from the kernel?
Would it be possible for the user to develop a new command interpreter using the system-call
interface provided by the operating system?

Answer: 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
the command interpreter is subject to changes. An user should be able to develop a new
command interpreter using the system-call interface provided by the operating system. The
command interpreter allows an user to create and manage processes and also determine ways by
which they communicate (such as through pipes and files). As all of this functionality could be
accessed

Q5. What are the advantages and disadvantages of using the same system-call interface for
manipulating both files and devices?

Answer: 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 in-terface, it is relatively easy to add a new device
driver by implementing the hardware-specific code to support this abstract file interface. There-
fore, 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 with using the same interface is that it might be difficult to
capture the functionality of certain devices within the context of the file access API, thereby
either resulting in a loss of functionality or a loss of performance. Some of this could be
overcome by the use of ioctl oper-ation that provides a general purpose interface for processes to
invoke operations on devices.

System programs

Q1. Explain briefly about, processor, assembler, compiler, loader, linker and the functions
executed by them. [Interview Question]

Answer : Processor:–A processor is the part a computer system that executes instructions It is
also called a CPU

Assembler: — An assembler is a program that takes basic computer instructions and converts
them into a pattern of bits that the computer’s processor can use to perform its basic operations.
Some people call these instructions assembler language and others use the term assembly
language.

Compiler: — A compiler is a special program that processes statements written in a particular


programming language and turns them into machine language or “code” that a computer’s
processor uses. Typically, a programmer writes language statements in a language such as Pascal
or C one line at a time using an editor. The file that is created contains what are called the source
statements. The programmer then runs the appropriate language compiler, specifying the name of
the file that contains the source statements.

Loader:–In a computer operating system, a loader is a component that locates a given program
(which can be an application or, in some cases, part of the operating system itself) in offline
storage (such as a hard disk), loads it into main storage (in a personal computer, it’s called
random access memory), and gives that program control of the compute

Linker: — Linker performs the linking of libraries with the object code to make the object code
into an executable machine code.

Q2. How could a system be designed to allow a choice of operating systems to boot from? What
would the bootstrap program need to do?

Answer: Consider a system that would like to run both Windows XP and three different
distributions of Linux (e.g., RedHat, Debian, and Mandrake). Each operating system will be
stored on disk. During system boot-up, a special program (which we will call the boot manager)
will boot manager determine which operating system to boot into. This means that rather initially
booting to an operating system, the boot manager will first run during system start-up. It is this
boot manager that is responsible for determining which system to boot into. Typically boot
managers must be stored at certain locations of the hard disk to be recognized during system
start-up. Boot managers often provide the user with a selection of systems to boot into; boot
managers are also typically designed to boot into a default operating system if no choice is
selected by the user.

Operating System Design and implementation

Q1.What is the main advantage for an operating-system designer of using virtual-machine


architecture? What is the main advantage for a user?[text book2.14]

Answer: The system is easy to debug, and security problems are easy to solve. Virtual machines
also provide a good platform for operating system research since many different operating
systems may run on one physical system.

Q2. Why is the separation of mechanism and policy desirable?

Answer: Mechanism and policy must be separate to ensure that systems are easy to modify. No
two system installations are the same, so each installation may want to tune the operating system
to suit its needs. With mechanism and policy separate, the policy may be changed at will while
the mechanism stays unchanged. This arrangement provides a more flexible system.

Operating system Structure

Q 1. Discuss the Simple Operating System Structure. Describe the layers of the Kernel. [2016]

Q2. Explain the difference between micro-kernel and macro-kernel.[2016]

Q3. It is sometimes difficult to achieve a layered approach if two components of the operating
system are dependent on each other. Identify a scenario in which it is unclear how to layer two
system components that require tight coupling of their functionalities.

Answer: The virtual memory subsystem and the storage subsystem are typically tightly-coupled
and requires careful design in a layered system due to the following interactions. Many systems
allow files to be mapped into the virtual memory space of an executing process. On the other
hand, the virtual memory subsystem typically uses the storage system to provide the backing
store for pages that do not currently re-side in memory. Also, updates to the filesystem are
sometimes buffered in physical memory before it is flushed to disk, thereby requiring care-ful
coordination of the usage of memory between the virtual memory subsystem and the filesystem.

Q2. What is the main advantage of the microkernel approach to system de-sign? How do user
programs and system services interact in a microker-nel architecture? What are the disadvantages
of using the microkernel approach?

Answer: 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 reli-
able operating system. User programs and system services interact in a microkernel architecture
by using interprocess communication mecha-nisms such as messaging. These messages are
conveyed by the operating system. The primary disadvantage of the microkernel architecture are
the overheads associated with interprocess communication and the fre-quent use of the operating
system’s messaging functions in order to enable the user process and the system service to
interact with each other.

Q3. What is the main advantage of the layered approach to system design? [textbook2.10]
Answer: As in all cases of modular design, designing an operating system in a modularway has
several advantages. The system is easier to debug and modify because changesaffect only limited
sections of the system rather than touching all sections of the operatingsystem. Information is
kept only where it is needed and is accessible only within a definedand restricted area, so any
bugs affecting that data must be limited to a specific module orlayer.

Q4. The experimental Synthesis operating system has an assembler incorpo-rated within the
kernel. To optimize system-call performance, the kernel assembles routines within kernel space
to minimize the path that the sys-tem call must take through the kernel. This approach is the
antithesis of the layered approach, in which the path through the kernel is extended to make
building the operating system easier. Discuss the pros and cons of the Synthesis approach to
kernel design and to system-performance optimization.

Answer: Synthesis is impressive due to the performance it achieves through on-the-fly


compilation. Unfortunately, it is difficult to debug problems within the kernel due to the fluidity
of the code. Also, such compilation is system specific, making Synthesis difficult to port (a new
compiler must be written for each architecture).

Q5. In what ways is the modular kernel approach similar to the layered approach? In what ways
does it differ from the layered approach?

Answer: The modular kernel approach requires subsystems to interact with each other through
carefully constructed interfaces that are typi-cally narrow (in terms of the functionality that is
exposed to external modules). The layered kernel approach is similar in that respect. How-ever,
the layered kernel imposes a strict ordering of subsystems such that subsystems at the lower
layers are not allowed to invoke opera-tions corresponding to the upper-layer subsystems. There
are no such restrictions in the modular-kernel approach, wherein modules are free to invoke each
other without any constraints.

Q6.What is a layered approach and what is its advantage?

Answer: Layered approach is a step towards modularizing of the system, in which the operating
system is broken up into a number of layers (or levels), each built on top of lower layer. The
bottom layer is the hard ware and the top most is the user interface.The main advantage of the
layered approach is modularity. The layers are selected such that each uses the functions
(operations) and services of only lower layer. This approach simplifies the debugging and system
verification.
Q7. What is micro kernel approach and state its advantages?

Answer: Micro kernel approach is a step towards modularizing the operating system where all
nonessential components from the kernel are removed and implemented as system and user level
program, making the kernel smaller.The benefits of the micro kernel approach include the ease
of extending the operating system. All new services are added to the user space and consequently
do not require modification of the kernel. And as kernel is smaller it is easier to upgrade it. Also
this approach provides more security and reliability since most services are running as user
processes rather than kernel’s keeping the kernel intact.

Q 8. Explain the difference between micro-kernel and macro-kernel[year-2016]

Answer: Micro kernel is a kernel which run services those are minimal for operating system
performance. In this kernel all other operations are performed by processor. Macro Kernel is a
combination of micro and monolithic kernel. In monolithic kernel all operating system code is in
single executable image.

Virtual Machine
Q1. What are a virtual machines and site their advantages?[interview question]

Answer: It is the concept by which an operating system can create an illusion that a process has
its own processor with its own (virtual) memory. The operating system implements virtual
machine concept by using CPU scheduling and virtual memory. The basic advantage is it
provides robust level of security as each virtual machine is isolated from all other VM. Hence the
system resources are completely protected. Another advantage is that system development can be
done without disrupting normal operation. System programmers are given their own virtual
machine, and as system development is done on the virtual machine instead of on the actual
physical machine. Another advantage of the virtual machine is it solves the compatibility
problem. EX: Java supplied by Sun micro system provides a specification for java virtual
machine.

Q2. What is the relationship between a guest operating system and a host operating system in a
system like VMware? What factors need to be considered in choosing the host operating system?

Answer: A guest operating system provides its services by mapping them onto the functionality
provided by the host operating system. A key issue that needs to be considered in choosing the
host operating system is whether it is sufficiently general in terms of its system-call interface in
order to be able to support the functionality associated with the guest operating system.

Q3.Describe three general methods for passing parameters to the operating system.

Answer:
a. Pass parameters in registers
b. Registers pass starting addresses of blocks of parameters
c. Parameters can be placed, or pushed, onto the stack by the
program, and popped off the stack by the operating system.

Q4.Why is a just-in-time compiler useful for executing Java programs?

Answer: Java is an interpreted language. This means that the JVM inter-prets the bytecode
instructions one at a time. Typically, most interpreted environments are slower than running
native binaries, for the interpre-tation process requires converting each instruction into native
machine code. A just-in-time (JIT) compiler compiles the bytecode for a method into native
machine code the first time the method is encountered. This means that the Java program is
essentially running as a native appli-cation (of course, the conversion process of the JIT takes
time as well but not as much as bytecode interpretation.) Furthermore, the JIT caches compiled
code so that it may be reused the next time the method is en-countered. A Java program that is
run by a JIT rather than a traditional interpreter typically runs much faster.

Q5. Describe how you could obtain a statistical profile of the amount of time spent by a program
executing different sections of its code. Discuss the importance of obtaining such a statistical
profile.

Answer: One could issue periodic timer interrupts and monitor what instructions or what
sections of code are currently executing when the interrupts are delivered. A statistical profile of
which pieces of code were active should be consistent with the time spent by the program in
different sections of its code. Once such a statistical profile has been obtained, the programmer
could optimize those sections of code that are consuming more of the CPU resources.

Q6. 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.

You might also like