Professional Documents
Culture Documents
Unit 1 Qs Ans
Unit 1 Qs Ans
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.
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.
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.
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
∙ 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.
∙ 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.
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:
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
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
Ans
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.
• Problem: We cannot allow a user-program to get stuck in an infinite loop and never return
control to the OS.
• Working procedure:
• The instructions that modify the content of the timer are privileged instructions.
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.
Device drivers are loaded into the running kernel and become part of the kernel.
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 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.
Any changes to the kernel tend to be fewer, since the kernel is smaller.
A Microkernel architecture.
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.
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.
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
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
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:
In the non-multiprogramming environment, the user/program has to wait for CPU much time.
But waiting time is limited in multiprogramming.
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:
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 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.