Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

1. Discuss in detail the main advantages of the layered approach to system design?

What are the


disadvantages of using layered approach?

Layered Approach
 In Layered approach the operating system is broken into several layers (levels).
 The bottom layer 0 is the Hardware and the highest layer N is User interface.
 An operating-system layer consists of data structures and a set of routines that can be
invoked by higher-level layers and can also invoke operations on lower-level layers.
 An operating-system layer is an implementation of an abstract object made up of data
and the operations that can manipulate those data.

Advantages of Layered Approach


The main advantage of the layered approach is simplicity of construction and debugging.
 Each layer uses functions (operations) and services of only lower-level layers.
 This approach simplifies debugging and system verification.
 The first layer can be debugged without any concern for the rest of the system because
it uses only the basic hardware to implement its functions.
 Once the first layer is debugged and functions correctly while the second layer is
debugged and so on.
 If an error is found during the debugging of a particular layer, the error must be on that
layer, because the layers below it is already debugged.
Other advantage of Layered structure is Data Hiding:
 Each layer is implemented only with operations provided by lower-level layers.
 A layer does not need to know how these operations are implemented instead a layer
just knows what these operations do.
 Hence, each layer hides the existence of certain data structures, operations, and
hardware from higher-level layers.
Problems with Layered Approach
Major difficulty with the layered approach involves appropriately defining the various layers.
 A layer can use only lower-level layers hence we have plan carefully which layer to be
kept in which place.
 Example: The device driver for the backing store (i.e., disk space used by virtual-memory
algorithms) must be at a lower level than the memory-management routines, because
memory management requires the ability to use the backing store.
 The backing-store driver would normally be above the CPU scheduler because the driver
may need to wait for I/O and the CPU can be rescheduled during this time.
Other problem with layered implementations is that they tend to be less efficient.
 When a user program executes an I/O operation, it executes a system call that is trapped
to the I/O layer, which calls the memory-management layer, which in turn calls the CPU-
scheduling layer, which is then passed to the hardware.
 At each layer, the parameters may be modified, data may need to be passed and so on.
Each layer adds overhead to the system call.
 The net result is a system call that takes longer time than a non-layered system.

2. Explain about various types of System calls.

TYPES OF SYSTEM CALLS


System calls can be grouped into six major categories:
1. Process Control
2. File Manipulation
3. Device Manipulation
4. Information Maintenance
5. Communications
6. Protection
Process Control System Calls
The list of process control system calls is:
 create process () is used to create a new process.
 terminate process () is used to terminate the process that have already created.
 load () and execute (): A process or job executing one program may want to load( ) and
execute( ) another program.
 end (): It is used when a running program needs to be able to halt its execution normally.
 abort (): It is used when a running program needs to be able to halt its execution
abnormally.
 wait event () After creating new processes, it may need to wait for a certain amount of
time to pass to finish its execution.
 signal event( ): The jobs or processes signals when an event has occurred.
 get process attributes( ) and set process attributes( ) are used to control execution of a
process.
 acquire lock( ) or release lock( ): Acquire lock ( ) is used to lock the process and release
lock( ) is used to release the lock on process.

File Management
 create( ) is used to create a new file and delete( ) is used to delete an existing file.
 Every file have some attributes includes file name, file type, protection codes,
accounting information and so on. get file attributes( ) and set file attributes( ) are the
system calls used to retrieve and get values of attributes.
 open( ) is used to open already created file.
 After opening a file, it may be read( ), write( ), or reposition( ).
 Close( ): After all the operations are performed with the file, the file needs to be close.
Device Management
 A process may need several resources to execute such as 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 operating system such as disk drives, files etc.
 A system with multiple users may require us to first request( ) a device to use it.
 Once the device has been requested, we can read( ), write( ) and reposition( ) the device.
 After we are finished with the device, we release( ) it.
Information Maintenance
Many system calls exist simply for the purpose of transferring information between the user
program and the operating system.
 Most systems have a system call to return the current time( ) and date( ).
 dump( ) system calls is helpful in debugging a program.
 Other system calls may return information about the system, such as the number of
current users, the version number of the operating system, the amount of free memory
or disk space and so on.
Communication
There are two common models of inter-process communication: Message passing model and
the Shared-memory model.
In Message-passing model, the communicating processes exchange messages with one
another to transfer information by establishing an internet connection.
 Messages can be exchanged between the processes either directly or indirectly through
a common mailbox.
 Each computer in a network has a host name and each process has a process name.
 OS can refer to the process by translating Process name into process identifier.
 gethostid( ) and getprocessid( ) system calls used to retrieve host name and process id.
 open_connection( ) and close_connection( ) system calls used to opening and
closing the connection.
 accept_connection( ) is used to accept the connection by the receiptent.
In Shared-memory model, processes use shared memory create( ) and shared memory
attach( ) system calls to create and gain access to regions of memory owned by other
processes.
 Operating system tries to prevent one process from accessing another processes
memory.
 Shared memory requires that two or more processes agree to remove this restriction.
 They can exchange information by reading and writing data in the shared areas.

Protection
Protection provides a mechanism for controlling access to the resources provided by a
computer system.
 System calls providing protection include set_permission( ) and get_permission( ),
which manipulate the permission settings of resources such as files and disks.
 The allow_user( ) and deny_user( ) system calls specify whether particular users
can or cannot be allowed access to certain resources.

3. Explain about services of os?

An Operating system provides an environment for the execution of programs. OS


provides certain services to programs and to the users of those programs.

Operating system services are provided for the convenience of the programmer and to
make the programming task easier.

The list of Operating system services that are helpful to the user:
1. User interface
2. Program Execution
3. I/O Operation
4. File system manipulation
5. Communication
6. Error Detection
7. Resource allocation
8. Accounting
9. Protection and Security

User Interface
Almost all operating systems have a User Interface (UI). An UI is generally of 3 types: ∙
Command-Line Interface (CLI) uses text commands and a method for entering them. ∙
Batch Interface: The commands and directives to control those commands are entered
into files and those files are executed.

∙ Graphical User Interface (GUI) is a window system with a pointing device (i.e.
mouse) to direct I/O, choose from menus and make selections and a keyboard to enter
text. Program Execution

The system must be able to load a program into main memory and to run that program.
The program must be able to end its execution, either normally or abnormally. I/O
operations

A running program may require I/O, which may involve a file or an I/O device. Example
are blanking a display screen, recording to a CD or DVD drive or.

File-system manipulation
∙ Programs need to read and write files and directories.
∙ They need to create and delete them by name, search for a file and list file information.
∙ Operating systems include permissions management to allow or deny access to files or
directories based on file ownership.

Communications
∙ One process in its life time needs to communicate with another process to exchange
information.

∙ Communication occurs between processes that are executing on the computer. ∙


Communications may be implemented via Shared Memory or Message Passing. ∙ In
Shared memory communication two or more processes read and write to a shared
section of memory.

∙ In Message passing communication the packets of information in predefined formats


are moved between processes by the operating system.

Error Detection
The operating system needs to be detecting and correcting errors constantly. The different
types of errors occurred are:

∙ CPU and Memory hardware errors such as a memory error or a power failure. ∙ I/O
devices errors such as a parity error on disk, a connection failure on a network, or lack of
paper in the printer

∙ User Program errors such as an arithmetic overflow, an attempt to access an illegal


memory location.

∙ For each type of error, the operating system should take the appropriate action to ensure
correct and consistent computing.

Resource Allocation
∙ When there are multiple users or multiple jobs running at the same time, resources must
be allocated to each of them.

∙ Operating system resources are CPU cycles, main memory, file storage, I/O devices
etc. ∙ The operating system manages many of these resources.

∙ CPU cycles, main memory and file storage may have special allocation code. I/O
devices may have much more general request and release code.

∙ In determining how best to use the CPU, operating systems have CPU-scheduling
routines that take into account the speed of the CPU, the jobs that must be executed,
the number of registers available and other factors.

∙ There may also be routines to allocate printers, USB storage drives and other peripheral
devices.

Accounting
∙ Operating system keeps track of different kind of resources used by all users. ∙ This
record keeping may be used for accounting so that users can be billed or simply for
accumulating usage statistics.

∙ Usage statistics are valuable tool for researchers who wish to reconfigure the system to
improve computing services.

Protection and security


∙ Protection ensures that all access to system resources is controlled because when several
separate processes execute concurrently, it should not be possible for one process to
interfere with the others or with the operating system itself.

∙ Security of the system defends the system from outsider’s attacks such as invalid access
of system resources such as I/O devices etc. Security starts with user authentication
by providing username and password to gain access to system resources.

4. Explain about System Calls in detail.

Ans) System calls provide a means for user or application programs to call upon the
services of the operating system.

 Generally written in C or C++, although some are written in assembly for optimal
performance.
 Figure illustrates the sequence of system calls required to copy a file:

Example of how system calls are used.

 You can use "strace" to see more examples of the large number of system calls invoked
by a single simple command. Read the man page for strace, and try some simple
examples. ( strace mkdir temp, strace cd temp, strace date > t.t, strace cp t.t t.2, etc. )
 Most programmers do not use the low-level system calls directly, but instead use an
"Application Programming Interface", API. The following sidebar shows the read( ) call
available in the API on UNIX based systems::

The use of APIs instead of direct system calls provides for greater program portability between
different systems. The API then makes the appropriate system calls through the system call
interface, using a table lookup to access specific numbered system calls, as shown in Figure

The handling of a user application invoking the open( ) system call

 Parameters are generally passed to system calls via registers, or less commonly, by values
pushed onto the stack. Large blocks of data are generally accessed indirectly, through a
memory address passed in a register or on the stack, as shown in Figure
Passing of parameters as a table

5. a. Explain the differences between multiprogramming and timesharing operating


systems?
b. Mention its advantages and disadvantages?

Ans

a. Difference between Time Sharing and Multiprogramming :


S.No. TIME SHARING MULTIPROGRAMMING

Time Sharing is the logical extension of


multiprogramming, in this time sharing Multiprogramming operating system
Operating system many users/processes allows to execute multiple processes
01 are allocated with computer resources in by monitoring their process states
. respective time slots. and switching in between processes.

Processor and memory


underutilization problem is resolved
Processors time is shared with multiple and multiple programs runs on CPU
02 users that’s why it is called as time sharing that’s why it is called
. operating system. multiprogramming.

In this process, two or more users


can use a processor in their In this, the process can be executed by a
03. terminal. single processor.

Time sharing OS has fixed time Multi-programming OS has no fixed time


04. slice. slice.
In time sharing OS system, In multi-programming OS system before
execution power is taken off finishing a task the execution power is not
05. before finishing of execution. taken off.

Here the system works for the


same or less time on each Here the system does not take same time to
06. processes. work on different processes.

In time sharing OS system In Multiprogramming OS, system depends


depends on time to switch on devices to switch between tasks such I/O
07. between different processes. interrupts etc.

System model of time sharing system is System model of multiprogramming


08. multiple programs and multiple users. system is multiple programs.

Time sharing system maximizes Multiprogramming system maximizes


09. response time. response time.

10. Example: Windows NT. Example: Mac OS.

b. Time Sharing OS
Benefits:
 Quick response.
 Reduces CPU idle time.
 All the tasks are given specific time.
 Less probability of duplication of software.
 Improves response time.
Disadvantages:
 It consumes much resources.
 Requires high specification of hardware.
 It has a problem of reliability.
 Security and Integrity concerns.
 Probability of data communication problem.

Multiprogramming OS
Benefits :
 No CPU idle time.
 Tasks runs in parallel.
 Shorter response time.
 Maximizes total job throughput of a computer.
 Increases resource utilization.
Disadvantages:
 Sometimes long-time jobs must wait long time.
 Tracking of all processes sometimes difficult.
 Requires CPU scheduling.
 Requires efficient memory management.
 No user interaction with any program during execution.

6. Explain about operating systems operations in detail


Ans: Operating System Operations
• Modern OS is interrupt driven.
• Events are always signaled by the occurrence of an interrupt or a trap.
• A trap is a software generated interrupt caused either by
o error (for example division by zero) or
o request from a user-program that an OS service be performed.
• For each type of interrupt, separate segments of code in the OS determine what action
should be taken.
• ISR (interrupt service routine) is provided that is responsible for dealing with the
interrupt.
Dual Mode Operation
• Problem: We must be able to differentiate between the execution of
o OS code and
o user-defined code.
• Solution: Most computers provide hardware-support.
• We have two modes of operation (Figure 1.9):
o User mode and
o Kernel mode
• A mode bit is a bit added to the hardware of the computer to indicate the current mode:
i.e. kernel (0) or user (1)
Working principle:
o At system boot time, the hardware starts in kernel-mode.
o The OS is then loaded and starts user applications in user-mode.
o Whenever a trap or interrupt occurs, the hardware switches from user-mode to kernel-
mode (that is, changes the state of the mode bit to 0).
o The system always switches to user-mode (by setting the mode bit to 1) before passing
control to a user-program.
• Dual mode protects
o OS from errant users and
o errant users from one another.
• Privileged instruction is executed only in kernel-mode.
• If an attempt is made to execute a privileged instruction in user-mode, the hardware
treats it as illegal and traps it to the OS.
• A system calls are called by user-program to ask the OS to perform the tasks on behalf
of the user program.
Timer

• Problem: We cannot allow a user-program to get stuck in an infinite loop and never return
control to the OS.

• Solution: We can use a timer.

• A timer can be set to interrupt the computer after a specific period.

• The period may be

o fixed (for ex: 1/60 second) or

o variable (for ex: from 1ns to 1ms).

• A variable timer is implemented by

o a fixed-rate clock and


o a counter.

• Working procedure:

o The OS sets the counter.

o Every time the clock ticks, the counter is decremented.

o When the counter reaches 0, an interrupt occurs.

• The instructions that modify the content of the timer are privileged instructions.

7. Explain about the structure of OS

1.10. Operating-System Structure¶

1.10.1. Simple Structure

In MS-DOS, applications may bypass the operating system.

Operating systems such as MS-DOS and the original UNIX did not have well-defined structures.

There was no CPU Execution Mode (user and kernel), and so errors in applications could cause
the whole system to crash.

1.10.2. Monolithic Approach


Functionality of the OS is invoked with simple function calls within the kernel, which is one large
program.

Device drivers are loaded into the running kernel and become part of the kernel.

A monolithic kernel, such as Linux and other Unix systems.

1.10.3. Layered Approach

This approach breaks up the operating system into different layers.

This allows implementers to change the inner workings, and increases modularity.

As long as the external interface of the routines don’t change, developers have more freedom
to change the inner workings of the routines.

With the layered approach, the bottom layer is the hardware, while the highest layer is the user
interface.

The main advantage is simplicity of construction and debugging.

The main difficulty is defining the various layers.


The main disadvantage is that the OS tends to be less efficient than other implementations.

The Microsoft Windows NT Operating System. The lowest level is a monolithic kernel, but many
OS components are at a higher level, but still part of the OS.

1.10.4. Microkernels

This structures the operating system by removing all nonessential portions of the kernel and
implementing them as system and user level programs.

Generally, they provide minimal process and memory management, and a communications
facility.

Communication between components of the OS is provided by message passing.

The benefits of the microkernel are as follows:

Extending the operating system becomes much easier.

Any changes to the kernel tend to be fewer, since the kernel is smaller.

The microkernel also provides more security and reliability.


Main disadvantage is poor performance due to increased system overhead from message
passing.

A Microkernel architecture.

8. Describe evolution of operating system in detail

Evolution of OS

Evolution of OS since 1950 described in detail in this article. Here we will discuss six main
operating system types evaluated over the past 70 years.

Evolution of Operating System


Serial Processing

History of the operating system started in 1950. Before 1950, the programmers directly interact
with the hardware there was no operating system at that time. If a programmer wishes to
execute a program on those days, the following serial steps are necessary.

Type the program or punched card.

Convert the punched card to a card reader.

submit to the computing machine, is there any errors, the error was indicated by the lights.

The programmer examined the register and main memory to identify the cause of an error

Take outputs on the printers.

Then the programmer ready for the next program.

Drawback:

This type of processing is difficult for users, it takes much time and the next program should
wait for the completion of the previous one. The programs are submitted to the machine one
after one, therefore the method is said to be serial processing.

Batch Processing

Before 1960, it is difficult to execute a program using a computer because of the computer
located in three different rooms, one room for the card reader, one room for executing the
program and another room for printing the result.

The user/machine operator runs between three rooms to complete a job. We can solve this
problem by using batch processing.

In batch processing technique, the same type of jobs batch together and execute at a time. The
carrier carries the group of jobs at a time from one room to another.
Therefore, the programmer need not run between these three rooms several times.

Multiprogramming

Multiprogramming is a technique to execute the number of programs simultaneously by a


single processor. In multiprogramming, a number of processes reside in main memory at a
time. The OS(Operating System) picks and begins to execute one of the jobs in main memory.
Consider the following figure, it depicts the layout of the multiprogramming system. The main
memory consisting of 5 jobs at a time, the CPU executes one by one.
Multiprogramming

In the non-multiprogramming system, the CPU can execute only one program at a time, if the
running program is waiting for any I/O device, the CPU becomes idle so it will effect on the
performance of the CPU.

But in a multiprogramming environment, if any I/O wait happened in a process, then the CPU
switches from that job to another job in the job pool. So, the CPU is not idle at any time.

Advantages:

Can get efficient memory utilization.

CPU is never idle so the performance of CPU will increase.

The throughput of CPU may also increase.

In the non-multiprogramming environment, the user/program has to wait for CPU much time.
But waiting time is limited in multiprogramming.

Time Sharing System

Time-sharing or multitasking is a logical extension of multiprogramming. Multiple jobs are


executed by the CPU switching between them. The CPU scheduler selects a job from the ready
queue and switches the CPU to that job. When the time slot expires, the CPU switches from this
job to another.
In this method, the CPU time is shared by different processes. So, it is said to be "Time-Sharing
System". Generally, time slots are defined by the operating system.

Advantages:

The main advantage of the time-sharing system is efficient CPU utilization. It was developed to
provide interactive use of a computer system at a reasonable cost. A time shared OS uses CPU
scheduling and multiprogramming to provide each user with a small portion of a time-shared
computer.

Another advantage of the time-sharing system over the batch processing system is, the user
can interact with the job when it is executing, but it is not possible in batch systems.

Parallel System

There is a trend multiprocessor system, such system have more than one processor in close
communication, sharing the computer bus, the clock, and sometimes memory and peripheral
devices.

These systems are referred to as "Tightly Coupled" system. Then the system is called a parallel
system. In the parallel system, a number of processors are executing there job in parallel.

Advantages:

It increases the throughput.

By increasing the number of processors(CPU), to get more work done in a shorter period of
time.

Distributed System

In a distributed operating system, the processors cannot share a memory or a clock, each
processor has its own local memory. The processor communicates with one another through
various communication lines, such as high-speed buses. These systems are referred to as
"Loosely Coupled" systems.

Advantages:

If a number of sites connected by high-speed communication lines, it is possible to share the


resources from one site to another site, for example, s1 and s2 are two sites. These are
connected by some communication lines. The site s1 having a printer, but the site does not
have any print. Then the system can be altered without moving from s2 to s1. Therefore,
resource sharing is possible in the distributed operating system.
A big computer that is partitioned into a number of partitions, these sub-partitions are run
concurrently in distributed systems.

If a resource or a system fails in one site due to technical problems, we can use other
systems/resources in some other sites. So, the reliability will increase in the distributed system.

You might also like