Introduction To OS
Introduction To OS
Roles Of OS
• Implementing the user interface
• Sharing hardware among users
• Allowing users to share data among themselves
• Preventing users from interfering with one another
• Scheduling resources among users
• Facilitating input/output
• Recovering from errors
• Accounting for resource usage
• Facilitating parallel operations
• Organizing data for secure and rapid access
• Handling network communications
© Er. Rajan Karmacharya ‐2013 Page 1 of 12
Unit 1: Introduction To Operating Systems
Two Functions of OS
1. OS as an extended machine
o OS creates a high level of abstraction for the programmer
Example—(Floppy Disk I/O Operation)
• Disk contains a list of named files
• Each file can be opened for read write
• After read write is complete, close that file
• No any detail to deal
o The abstraction hides the truth about the hardware from the programmer and presents a
simple view of the named files that can be read and written.
o OS prevents the user with the equivalent of an extended machine or virtual machine that is
easier to program than the underlying hardware.
2. OS as a Resource Manager
o What happens if three programs try to print their output on the same printer at the same time
o What happens if two network users try to update a shared document at the same time?
o OS primary function is to keep track of who is using which resource to grant resource
requests, to account for usage and to mediate conflicting requests from different programs
and users
o Virtualizes resources so multiple users can share it
o Protect application from one another
o Provide efficient and fair access to resource
History Of OS
Operating systems have evolved through a number of distinct phases or generations which corresponds
roughly to the decades.
Multiprogramming
• When one job needs to wait for I/O, the processor can switch to the other job
• May be either
o Hard Real Time:
Well defined fixed time constraints, processing must be done within the defined
constraints, or the system will fail. (e.g. use of brake in car)
o Soft Real Time System:
Less stringent timing constraints and does not support the dead line scheduling
The value of job degrades as the dead line passes (e.g. late attendance in exam hall)
Assume that there are four interactive users with the following memory requirements:
JOB1: 15,000 JOB2: 20,000 JOB3:5000 JOB4: 10,000
Initially, the monitor loads in JOB1 and transfers control to it (a). Later the monitor decides to transfer control
to JOB2. Because JOB2 requires more memory than JOB1, JOB1 must be written our first, and then JOB2
can be loaded (b). Next JOB2 is loaded in to be run. However, because JOB3 is smaller than JOB2, a
portion of JOB2 can remain in memory, reducing disk write time (c). Later, the monitor decides to transfer
control back to JOB1. An additional portion of JOB2 must be written our when JOB1 is loaded back into
memory (d). When JOB4 is loaded, part of JOB1 and the portion of JOB2 remaining in memory are retained
(e). At this point, if either JOB1 or JOB2 is activated, only a partial load will be required. In this example, it is
JOB2 that runs next. This requires that JOB4 and the remaining resident portion of JOB1 be written our and
that the missing portion of JOB2 be read in.
• Memory Hierarchy
Fast and Expensive
Performance:
The Shell
• In computing, a shell is a piece of software that provides an interface for users and provides access to
the services of a kernel.
• Operating system shells generally fall into one of two categories: command-line and graphical.
• Command-line shells provide a command-line interface (CLI) to the operating system, while graphical
shells provide a graphical user interface (GUI).
• In either category the primary purpose of the shell is to invoke or "launch" another program; however,
shells frequently have additional capabilities such as viewing the contents of directories.
Unix Shell
Many shells exist in Unix, including
o Bourne shell (sh)
o Almquist shell (ash)
o Debian Almquist shell (dash)
o Bourne-Again shell (bash)
o Korn shell (ksh)
o Z shell (zsh)
o C shell (csh)
o Stand-alone Shell (sash)
All of them support the functionality described below, which derives from the original shell (sh).
When any user logs in, a shell is started up. It starts out by typing the prompt, a character such as a dollar
sign, which tell the user that the shell is waiting to accept a command.
sort <file1>file2 (invokes the sort program with input take from file1 and output sent to file2)
cat file1 file2 file3 | sort>/dev/lp ( invokes the cat program to concatenate three files and send the output to
sort to arrange all the lines in alphabetical order). The output of sort is redirected to the file /dev/lp, typically
the printer.
Monolithic Systems
• The OS in it is written as a collection of procedures, each of which can call any of the other ones
whenever it needs to.
• This structure is subtitled "The Big Mess". The structure is that there is no structure.
• In this technique each procedure is free to call any other one, if the latter provides some useful
computation than the former needs.
• To construct the actual object of the operating system when this approach is used, one first compiles
all the individuals' procedures, or files containing the procedures and then binds them all together into
a single object file using the system linker.
• In terms of information hiding, there is essentially none – every procedure is visible to every other
procedure.
Layered Systems
• To generalize the monolithic system into the hierarchy of layers, the first system called THE was built by
E.W. Dijkstra in 1986.
• This system had 6 layers.
Virtual Machines
• Initial release of OS/360 were strictly batch systems
• Many 360 users wanted to have time sharing and IBM developed a machine originally called
CP/CMS and later named VM/370
• The heart of the system, known as the virtual machine monitor, runs on the bare hardware and does
the multiprogramming, providing not only one, but several virtual machines to the next layer up.
• The virtual machines are not the extended machines but are the exact copies of the bare hardware
including kernel/user mode, I/O, interrupts and everything else the real machine has.
• The CMS (Conversational Monitor System) is for interactive sharing users.
• To request a service, such as reading a block of a file, a client process send request to the server
process, this then does the work and sends back the answer.
• By splitting OS into parts, each of which handles only a facet of the system, such as file service,
process service, terminal service each part becomes small and manageable.
• Furthermore, because all servers run in the user mode, they don't have direct access to the hardware.
As a result, if a bug is triggered in the file server, the file service may crash, but the machine would not
be down.