OS Module-1 Notes

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 58

Operating System Unit – 1 - Introduction to Operating Systems, System structures

UNIT-1: INTRODUCTION TO OPERATING SYSTEMS, SYSTEM STRUCTURES

 An Operating System is a program that manages the computer hardware. It also provides
a basis for application programs and acts as an intermediary between the computer user
and the computer hardware.
 Operating systems are designed to be convenient, others to be efficient, and others some
combination of the two.

1.1. WHAT OPERATING SYSTEMS DO?


 A computer system can be divided roughly into four components: the hardware, the
operating system, the application programs and the users.
 The hardware – the central processing unit (CPU), the memory, and the input/output (I/O)
devices – provides the basic computing resources for the system.
 The Application programs – such as word processors, spreadsheets, compilers, and Web
browsers-define the ways in which these resources are used to solve users' computing
problems.
 The operating system controls the hardware and coordinates its use among the various
application programs for the various users.

Dept of CSE, Vemana I.T Page 1 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Fig 1.1: Components of Computer System


 The two viewpoints of the Operating System
 User View
 System View

 User View:
 The user view of the computer depends on the interface used.
 Some users may use PC’s. In this the system is designed so that only one user can utilize
the resources and mostly for ease of use where the attention is mainly on performances
and not on the resource utilization.
 Some users may use a terminal connected to a mainframe or minicomputers.
 Other users may access the same computer through other terminals. These users may
share resources and exchange information. In this case the OS is designed to maximize
resource utilization- so that all available CPU time, memory & I/O are used efficiently.
 Other users may sit at workstations, connected to the networks of other workstation and
servers. In this case OS is designed to compromise between individual visibility &
resource utilization.

 System View
 We can view system as resource allocator i.e. a computer system has many resources
that may be used to solve a problem. The OS acts as a manager of these resources. The
OS must decide how to allocate these resources to programs and the users so that it can
operate the computer system efficiently and fairly.
 A different view of an OS is that it need to control various I/O devices & user programs
i.e. an OS is a control program used to manage the execution of user program to prevent
errors and improper use of the computer.
 Resources can be either CPU Time, memory space, file storage space, I/O devices and so
on.

Dept of CSE, Vemana I.T Page 2 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Defining Operating System


The OS must support the following tasks
a. Provide the facility to create, modification of programs & data files using on editors.
b. Access to compilers for translating the user program from high level language to
machine language.
c. Provide a loader program to move the compiled program code to computers memory
for execution.
d. Provides routines that handle the details of I/O programming.

1.2. COMPUTER SYSTEM ORGANIZATION:


 Computer System Operation
 A modern general-purpose computer system consists of one or more CPUs and a number
of device controllers connected through a common bus that provides access to shared
memory (Figure 1.2).

Figure 1.2: A Modern Computer System

Dept of CSE, Vemana I.T Page 3 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Each device controller is in charge of a specific type of device (for example, disk drives,
audio devices, and video displays). The CPU and the device controllers can execute
concurrently, competing for memory cycles.
 To ensure orderly access to the shared memory, a memory controller is provided whose
function is to synchronize access to the memory.
 Bootstrap program - For a computer to start running, when it is powered up or
rebooted-it needs to have an initial program to run.
 Bootstrap program is stored in ROM or electrically erasable programmable read-only
memory (EPROM) known by the general term firmware within the computer hardware.
 The occurrence of an event is usually signaled by an Interrupt from either the hardware
or the software. Hardware may trigger an interrupt at any time by sending a signal to the
CPU, usually by way of the system bus. Software may trigger an interrupt by executing a
special operation called system call (Monitor call).

 When the CPU is interrupted, it stops what it is doing and immediately transfers
execution to a fixed location. The fixed location usually contains the starting address
where the service routine for the interrupt is located.
 The interrupt service routine executes; on completion, the CPU resumes the interrupted
computation. A time line of this operation is shown in Figure 1.3.

Figure 1.3. Interrupt time line for a single process doing output.

Dept of CSE, Vemana I.T Page 4 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Interrupt transfers control to the interrupt service routine generally, through the
interrupt vector, which contains the addresses of all the service routines.
 Interrupt architecture must save the address of the interrupted instruction.
 Incoming interrupts are disabled while another interrupt is being processed to prevent a
lost interrupt.
 A trap is a software-generated interrupt caused either by an error or a user request.
 An operating system is interrupt driven. The operating system preserves the state of the
CPU by storing registers and the program counter
 To Determine which type of interrupt has occurred:
 Polling
 vectored interrupt system
 Separate segments of code determine what action should be taken for each type of
interrupt

 I/O Structure
 After I/O starts, control returns to user program only upon I/O completion
 Wait instruction idles the CPU until the next interrupt
 Wait loop (contention for memory access)
 At most one I/O request is outstanding at a time, no simultaneous I/O processing.

 After I/O starts, control returns to user program without waiting for I/O completion
 System call – request to the operating system to allow user to wait for I/O
completion
 Device-status table contains entry for each I/O device indicating its type, address,
and state
 Operating system indexes into I/O device table to determine device status and to
modify table entry to include interrupt.

 Direct Memory Access Structure


 Used for high-speed I/O devices able to transmit information at close to memory
speeds.

Dept of CSE, Vemana I.T Page 5 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Device controller transfers blocks of data from buffer storage directly to main
memory without CPU intervention.
 Only one interrupt is generated per block, rather than the one interrupt per byte.
 Figure 1.5 shows all components of computer system.

Figure 1.5. How a modern computer system works.

 Storage Structure
 The CPU can load instructions only from memory, so any programs to run must be stored
there.
 General-purpose computers run most of their programs from rewriteable memory, called
main memory (also called Random Access Memory or RAM).
 Main memory commonly is implemented in a semiconductor technology called Dynamic
Random Access Memory or DRAM.
 The read-only memory (ROM) cannot be changed, only static programs are stored there.
 EEPROM cannot be changed frequently and so contains mostly static programs. For
example, smart phones have EEPROM to store their factory-installed programs.
 All forms of memory provide an array of words. Each word has its own address.
Interaction is achieved through a sequence of load or store instructions to specific
memory addresses.

Dept of CSE, Vemana I.T Page 6 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 The load instruction moves a word from main memory to an internal register within the
CPU, whereas the store instruction moves the content of a register to main memory. The
CPU automatically loads instructions from main memory for execution.
 A typical instruction-execution cycle, as executed on a system with Von Neumann
architecture, first fetches an instruction from memory and stores that instruction in the
Instruction Register (IR).
 The instruction is then decoded and may cause operands to be fetched from memory and
stored in some internal register. After the instruction on the operands has been executed,
the result may be stored back in memory.

 The programs and data to reside in main memory permanently. This arrangement usually
is not possible for the following two reasons:
 Main memory is usually too small to store all needed programs and data permanently.
 Main memory is a volatile storage device that loses its contents when power is turned
off or otherwise lost.

 Computer systems provide secondary storage as an extension of main memory which can
hold large quantities of data permanently.
 The most commonly used secondary storage device is magnetic disk, which provides
storage for both programs and data.

 The wide variety of storage systems in a computer system can be organized in a hierarchy
(Figure 1.4) according to speed and cost.

Dept of CSE, Vemana I.T Page 7 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.4 Storage device hierarchy


 In addition to differing in speed and cost, the various storage system are either volatile or
non-volatile.
 Volatile storage loses its contents when the power to the device is removed so, non-
volatile storage is used such as electronic disk.
 An electronic disk can be designed to be either volatile or non-volatile.
 Another form of electronic disk is flash memory which is popular in cameras and
personal digital assistants (PDA) in robots.

1.3. COMPUTER SYSTEM ARCHITECTURE:


1.3.1 Single Processor Systems
 In a single processor system, there is one CPU capable of a general purpose instruction
set, including the instructions from the user process.
 All systems have special purpose processors which come in the form of device specific
processors, such as disk, keyboard and graphic controllers or in mainframes they may
come in the form of general purpose processors such as I/O processors that move data
rapidly among the components of the system.
 All special purpose processors run limited instruction set and do not run user process.

Dept of CSE, Vemana I.T Page 8 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Example: Disk controller microprocessor receives a sequence of requests from the main
CPU and implements its own queue and scheduling algorithm.
 PCs contain a microprocessor in the keyboard to convert the key strokes into codes to be
sent to the CPU.
 The use of special purpose microprocessors does not turn a single processor system into
a multiprocessor.

1.3.2 Multiprocessor Systems


 Multiprocessor systems or Parallel systems or tightly coupled systems have two or
more processors in close communication, sharing the computer bus, clock, and memory
and peripheral devices.
 Multiprocessor systems have three advantages
a. Increased Throughput: By increasing number of processors, we expect more work
done in less time. When multiple processors cooperate on a task, a certain amount of
overhead is incurred in keeping all the parts working correctly.
b. Economy of scale: Multiprocessor systems cost less compare to multi single-
processor systems because they share the peripherals, mass storage and power
supplies. If several programs operate on same data, it is cheaper to store those data
on one disk.
c. Increased Reliability: if the functions are distributed properly among the processors
then failure of one processor will not halt the system, only slows down.

 The ability to continue providing the service proportional to the level of surviving
hardware is called Graceful Degradation.
 A system goes beyond the graceful degradation are called fault tolerant, because they
suffer a failure of any single component and still continue operation.

 Multiprocessor systems are of two types


 Asymmetric multiprocessing architecture
 Symmetric multiprocessing architecture

Dept of CSE, Vemana I.T Page 9 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Asymmetric multiprocessing architecture


 In asymmetric multiprocessing, each processor is assigned a specific task. A master
processor controls the system; the other processor look to the master for the
instruction or have predefined tasks.
 This scheme defines master-slave relationship.
 The master processor schedules and allocates work to the slave processors.

 Symmetric multiprocessing architecture(SMP)


 In Symmetric multiprocessing, each processor performs all tasks within the operating
system.
 Here, all processors are peers; no master-slave relationship exists between processors.

 Example is Solaris, a commercial version of Unix designed by Sun Microsystems.

Figure 1.5. Symmetric multiprocessing architecture

 The benefit here is that many processes can run simultaneously – N processes can run if
N CPUs without causing a detoriation of performance.
 Care must be taken for Controlling I/O to ensure that the data reach to appropriate
processor otherwise one processor is sitting idle while another is overhead.

Dept of CSE, Vemana I.T Page 10 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Multiprocessing can cause a system to change its memory access model from uniform
memory access (UMA) to non-uniform memory access (NUMA).
 UMA is defined as the situation in which access to any RAM from any CPU takes the same
amount of time.

Figure 1.6. A Dual-Core Design


 Figure 1.6 shows dual-core design with two cores on the same chip. In this design, each
core has its own register set as well as its own local cache; other designs might use a
shared cache or a combination of local and shared caches.

 Blade Servers are a recent development in which multiple processor boards, I/0 boards,
and networking boards are placed in the same chassis.
 The difference between these and traditional multiprocessor systems is that each blade-
processor board boots independently and runs its own operating system.
 Some blade-server boards are multiprocessor as well, which blurs the lines between types
of computers.

1.3.3 Clustered Systems


 Clustered systems gather together multiple CPUs to accomplish computational work.
 Clustered systems differ from multiprocessor systems, however, in that they are
composed of two or more individual systems-or nodes-joined together.
 Clustered computers share storage and are closely linked via a LAN.
 Clustering is usually used to provide service; that is, service will continue even if one or
more systems in the cluster fail.
 High availability is generally obtained by adding a level of redundancy in the system.

Dept of CSE, Vemana I.T Page 11 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 A layer of cluster software runs on the cluster nodes. Each node can monitor one or more
of the others (over the LAN). If the monitored machine fails, the monitoring machine can
take ownership of its storage and restart the applications that were running on the failed
machine.

 BEOWULF CLUSTERS: Beowulf clusters are designed for solving high-performance


computing tasks.
 These clusters are built using commodity hard ware-such as personal computers-that are
connected via a simple local area network.
 Beowulf duster uses no one specific software package but rather consists of a set of open-
source software libraries that allow the computing nodes in the cluster to communicate
with one another.
 Beowulf clusters require no special hardware and operate using OPEN SOURCE software
that is freely available; they offer a low-cost strategy for building a high performance
computing cluster.
 Beowulf clusters built from collections of discarded personal computers are using
hundreds of computing nodes to solve computationally expensive problems in scientific
computing.

 Clustering can be structured Asymmetrically or Symmetrically.

 In Asymmetric clustering, one machine is in hot standby mode, while the other is
running the applications.
 The hot-standby host machine does nothing but monitor the active server. If that server
fails, the hot-standby host becomes the active server.

 In Symmetric mode, two or more hosts are running applications and are monitoring
each other. This mode is obviously more efficient, as it uses all of the available hardware.
It does require that more than one application be available to run.

Dept of CSE, Vemana I.T Page 12 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.7. General Structure of Clustered System.

1.4. COMPUTER SYSTEM STRUCTURE:


 The main aspect of operating system is the ability to multiprogram.
 A single user cannot keep either CPU or I/O devices busy all the times.
 Multiprogramming increases CPU utilization by organizing jobs (code & data) so that the
CPU always has one job to execute.

Multi programmed System:-


 If there are two or more programs in the memory at the same time sharing the processor,
this is referred as multi programmed OS.
 It increases the CPU utilization by organizing the jobs so that the CPU will always have one
job to execute.
 Jobs entering the systems are kept in memory.
 OS picks the job from memory & it executes it.
 Having several jobs in the memory at the same time requires some form of memory
management.
 Multi programmed systems monitors the state of all active program and system resources
and ensures that CPU is never idle until there are no jobs.
 While executing a particular job, if the job has to wait for any task like I/O operation to be
complete then the CPU will switch to some other jobs and starts executing it and when the
first job finishes waiting the CPU will switch back to that.

Dept of CSE, Vemana I.T Page 13 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 This will keep the CPU & I/O utilization busy.

 The following figure shows the memory layout of multi programmed OS

Figure 1.8. Memory Layout for a multiprogramming system.

Time sharing Systems:-


 Time sharing system or multi tasking is logical extension of multi programming systems.
The CPU executes multiple jobs by switching between them but the switching occurs so
frequently that user can interact with each program while it is running.
 An interactive & hands on system provides direct communication between the user and the
system. The user can give the instruction to the OS or program directly through key board
or mouse and waits for immediate results.
 A time shared system allows multiple users to use the computer simultaneously. Since each
action or commands are short in time shared systems only a small CPU time will be
available for each of the user.
 A time shared systems uses CPU scheduling and multi programming to provide each user a
small portion of time shared computers. When a process executes it will be executing for a
short time before it finishes or need to perform I/O. I/O is interactive i.e. O/P is to a display
for the user and the I/O is from a keyboard, mouse etc.
 Since it has to maintain several jobs at a time, system should have memory management &
protection.
 Time sharing systems are complex than the multi programmed systems. Since several jobs
are kept in memory they need memory management and protection. To obtain less
response time jobs are swapped in and out of main memory to disk. So disk will serve as

Dept of CSE, Vemana I.T Page 14 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

backing store for main memory. This can be achieved by using a technique called virtual
memory that allows for the execution of job i.e. not complete in memory.
 Time sharing system should also provide a file system & file system resides on collection of
disks so this need disk management. It supports concurrent execution, job synchronization
& communication.

1.5. OPERATING SYSTEM OPERATIONS:


 All operating system are interrupt driven. If there are no processes to execute, no I/O
devices to service, and no users to whom to respond, an OS will wait for something to
happen.
 Events are signaled by the interrupt called TRAP. A trap (is an exception) is a software
generated interrupt caused by an error (EX: division by zero or invalid memory access).

 The operating system and the users share the hardware and software resources of the
computer system.
 When sharing, if error in a program, might affect the execution of the program.
 Without protection against these sorts of errors, either the computer must execute only
one process at a time or all output must be suspect.

1.5.1 Dual-Mode Operation


 Dual-mode operation allows OS to protect itself and other system components
 Two separate modes of operation:
 User mode.
 Kernel mode (Supervisor mode or system mode or privileged mode

 A bit, called the mode bit, is added to the hardware of the computer to indicate the current
mode: kernel (0) or user (1).
 User mode when executing harmless code in user applications
 Kernel mode when executing potentially dangerous code in the system kernel.
 When a user application requests a service from the operating system (via a system call), it
must transition from user to kernel mode to fulfill the request shown in figure 1.9.

Dept of CSE, Vemana I.T Page 15 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.9. Transition from user to kernel mode.

 At system boot time, the hardware starts in kernel mode. The operating system is then
loaded and starts user applications in user mode.
 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).
 Whenever the operating system gains control of the computer, it is in kernel mode. The
system always switches to user mode (by setting the mode bit to 1) before passing control
to a user program.
 The dual mode of operation provides us with the means for protecting the operating
system from errant users-and errant users from one another.

 Some instructions designated as privileged, only executable in kernel mode.


 The hardware allows privileged instructions to be executed only in kernel mode.
 If an attempt is made to execute a privileged instruction in user mode, the hardware does
not execute the instruction but rather treats it as illegal and traps it to the operating
system.

Dept of CSE, Vemana I.T Page 16 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

1.5.2 Timer
 To prevent user program getting stuck in an infinite loop or not calling system services and
never returning control to the OS we use TIMER.
 A Timer can be set to interrupt the computer after a specified period.
 The period may be fixed (EX: 1/60 second) or variable (EX: from 1ms to 1second).
 Before turning over the control to the user, the OS ensures that the timer is set to interrupt.
If timer interrupts, control transfers automatically to OS.
 Timer is used to prevent a user program running long.
 Timer control is a privileged instruction, (requiring kernel mode. )

1.5. PROCESS MANAGEMENT:


 A process is a program in execution. It is a unit of work within the system.
 Program is a passive entity, process is an active entity.
 A time-shared user program such as a compiler is a process.
 A word-processing program being run by an individual user on a PC is a process.
 A system task, such as sending output to a printer, can also be a process.

 Process needs resources such as CPU, memory, I/O, files, Initialization data to accomplish
its task.
 Process termination requires reclaim of any reusable resources.
 Single-threaded process has one program counter specifying location of next instruction
to execute. Process executes instructions sequentially, one at a time, until completion.
 Multi-threaded process has one program counter per thread.
 Typically system has many processes, some user, and some operating system running
concurrently on one or more CPUs. Concurrency by multiplexing the CPUs among the
processes / threads.
 A process is the unit of work in a system. Such a system consists of a collection of
processes, some of which are operating-system processes (those that execute system code)
and the rest of which are user processes (those that execute user code). All these processes
can potentially execute concurrently – by multiplexing the CPU among them on a single
CPU.

Dept of CSE, Vemana I.T Page 17 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 The operating system is responsible for the following activities in connection with process
management:
 Creating and deleting both user and system processes
 Suspending and resuming processes
 Providing mechanisms for process synchronization
 Providing mechanisms for process communication
 Providing mechanisms for deadlock handling

1.6. MEMORY MANAGEMENT:


 Main Memory is the centre to the operation of the modern computer.
 Main Memory is the array of bytes ranging from hundreds of thousands to billions. Each
byte will have their own address.
 The central processor reads the instruction from main memory during instruction fetch
cycle & it both reads & writes the data during the data-fetch cycle. The I/O operation reads
and writes data in main memory.
 The main memory is generally a large storage device in which a CPU can address & access
directly.
 When a program is to be executed it must be loaded into memory & mapped to absolute
address. When it is executing it access the data & instruction from Memory by generating
absolute address. When the program terminates all available Memory will be returned
back.
 To improve the utilization of CPU & the response time several program will be kept in
memory.
 Several Memory management scheme are available & selection depends on the hardware
design of the system.

 The OS is responsible for the following activities.


 Keeping track of which part of the Memory is used & by whom.
 Deciding which process & data to move into & out of memory.
 Allocating & de allocating Memory space as needed.

Dept of CSE, Vemana I.T Page 18 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

1.6. STORAGE MANAGEMENT:


 The operating system abstracts from the physical properties of its storage devices to define a
logical storage unit, the file. The operating system maps files onto physical media and accesses
these files via the storage devices.

1.6.1. File-System Management:


 File management is one of the most visible component of an OS.
 Computer stores data on different types of physical media like Magnetic Disks, Magnetic
tapes, optical disks etc.
 For convenient use of the computer system the OS provides uniform logical view of
information storage.
 The OS maps file on to physical media & access these files via storage devices.
 A file is logical collection of information.
 File consists of both program & data. Data files may be numeric, alphabets or alphanumeric.
 Files can be organized into directories.

 The OS is responsible for the following activities,


 Creating & deleting of files.
 Creating & deleting directories.
 Supporting primitives for manipulating files & directories.
 Mapping files onto secondary storage.
 Backing up files on stable (Nonvolatile) storage media.

1.6.2. Mass-Storage Management:


 It is a mechanism where the computer system may store information in a way that it can be
retrieved later.
 They are used to store both data & programs.
 The programs & data are stored in main memory.
 Since the size of the memory is small & volatile Secondary storage devices is used.
 Magnetic disk is central importance of computer system.

 The OS is responsible for the following activities,

Dept of CSE, Vemana I.T Page 19 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Free space management.


 Storage allocation.
 Disk scheduling.

 The entire speed of computer system depends on the speed of the disk sub system.
 Magnetic tape drives and CD and DVD drives and Platters typical tertiary storage devices.
 The media (tapes and optical platters) vary between WORM (write once, read many times)
and RW (read-write) formats.

1.6.3. Caching:
 There are many cases in which a smaller higher-speed storage space serves as a cache, or
temporary storage, for some of the most frequently needed portions of larger slower
storage areas.
 The hierarchy of memory storage ranges from CPU registers to hard drives and external
storage. (See table below.)
 The OS is responsible for determining what information to store in what level of cache, and
when to transfer data from one level to another.
 The proper choice of cache management can have a profound impact on system
performance.
 Data read in from disk follows a migration path from the hard drive to main memory, then
to the CPU cache, and finally to the registers before it can be used, while data being written
follows the reverse path. Each step (other than the registers) will typically fetch more data
than is immediately needed, and cache the excess in order to satisfy future requests faster.
For writing, small amounts of data are frequently buffered until there is enough to fill an
entire "block" on the next output device in the chain.
 The issues get more complicated when multiple processes (or worse multiple computers)
access common data, as it is important to ensure that every access reaches the most up-to-
date copy of the cached data (amongst several copies in different cache levels. )
 Important principle, performed at many levels in a computer (in hardware, operating
system, software).
 Information in use copied from slower to faster storage temporarily.

Dept of CSE, Vemana I.T Page 20 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Movement between levels of storage hierarchy can be explicit or implicit, depending on


the hardware design and the controlling operating system software.

Figure 1.10. Performance of various levels of Storage.

 In multitasking environment, where CPU is switched back and forth among various
processes, care must be taken that, if several processes wish to access same file, then each
of these processes obtains recently updated value.
 When only one process executes at time, no such difficulties arises.
 Multitasking environments must be careful to use most recent value, no matter where it is
stored in the storage hierarchy.
 Multiprocessor environment must provide cache coherency in hardware such that all
CPUs have the most recent value in their cache.

Figure 1.11. Migration of Integer A from Disk to Register.

1.6.4. I/O Systems:

Dept of CSE, Vemana I.T Page 21 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Each I/O device has a device handler that resides in separate process associated with that
device.
 The I/O management consists of,
 A Memory management component that include buffering,, caching & spooling.
 General device-driver interface.
 Drivers for specific Hardware device.

1.7. PROTECTION AND SECURITY:


 Protection involves ensuring that no process access or interfere with resources to which
they are not entitled, either by design or by accident. ( E.g. "protection faults" when pointer
variables are misused. )
 Security involves protecting the system from deliberate attacks, either from legitimate
users of the system attempting to gain unauthorized access and privileges, or external
attackers attempting to access or damage the system.
 Modern computer system supports many users & allows the concurrent execution of
multiple processes organization rely on computers to store information. It necessary that
the information & devices must be protected from unauthorized users or processors.
 The protection is a mechanism for controlling the access of program, processes or users to
the resources defined by a computer system.
 Protection mechanism is implemented in OS to support various security policies.
 The goal of security system is to authenticate their access to any object.
 Protection can improve reliability by detecting latent errors at the interface B/w
component sub system.
 Protection domains are extensions of Hardware supervisor mode ability.
 Protection and security require the system to be able to distinguish among all its users.
Operating systems maintain a list of user names and associated user identifier(User IDs)
 These numerical IDs are unique, one per user.
 User sometimes needs escalate privileges to gain extra permissions for an activity.

1.7. DISTRIBUTED SYSTEMS:

Dept of CSE, Vemana I.T Page 22 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Distributed Systems consist of multiple, possibly heterogeneous, computers connected


together via a network and cooperating in some way, form, or fashion.
 Access to a shared resource increases computation speed, functionality, data availability
and reliability.
 A network is a communication path between two or more systems.
 Networks may range from small tight LANs to broad reaching WANs.
 A LAN (Local Area Network) connects computers within a room, a floor or a building.
 A WAN (Wide Area Network) usually links buildings, cities or countries.
 A MAN (Metropolitan Area Network) links buildings within a city.
 Network access speeds, throughputs, reliabilities, are all important issues.
 OS view of the network may range from just a special form of file access to complex well-
coordinated network operating systems.
 Shared resources may include files, CPU cycles, RAM, printers, and other resources.

 A network operating system is an OS that provides feature such as file sharing across the
network and includes communication.

 Advantages of Distributed Systems:-


 Resource sharing.
 Higher reliability.
 Better price performance ratio.
 Shorter response time.
 Higher throughput.
 Incremental growth

1.7. SPECIAL-PURPOSE SYSTEMS:


 Real-Time Embedded Systems
 Multimedia Systems
 Handheld Systems.

1.7.1. Real-Time Embedded Systems:

Dept of CSE, Vemana I.T Page 23 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Embedded into devices such as automobiles, climate control systems, process control, and
even toasters and refrigerators.
 May involve specialized chips, or generic CPUs applied to a particular task. (Consider the
current price of 80286 or even 8086 or 8088 chips, which are still plenty powerful enough
for simple electronic devices such as kids toys.)
 Process control devices require real-time (interrupt driven ) OS. Response time can be
critical for many such devices.
 Embedded systems almost always run Real-Time operating systems. A real-time system is
used when rigid time requirements been placed on the operation of a processor or the flow
of data; thus, it is often used as a control device in a dedicated application.
 Sensors bring data to the computer. The computer must analyze the data and possibly
adjust controls to modify the sensor inputs.
 A real-time system has well-defined, fixed time constraints. Processing must be done within
the defined constraints, or the system will fail.
 A real-time system functions correctly only if it returns the correct result within its time
constraints.

1.7.2. Multimedia Systems:


 Multimedia data consists of Audio visual data, requiring real-time transmission, such as

cable TV boxes or wireless devices.


 Multimedia describes a wide range of applications in popular use today. These include
audio files such as MP3, DVD movies, video conferencing, and short video clips of movie
previews or news stories downloaded over the Internet.
 Multimedia applications may also include live webcasts (broadcasting over the World Wide
Web) of speeches or sporting events.
 Multimedia applications need not be either audio or video; rather, a multimedia application
often includes a combination of both.
 For example, a movie may consist of separate audio and video tracks.
 Multimedia is being directed toward smaller devices, including PDAs and cellular
telephones. For example, a stock trader may have stock quotes delivered wirelessly and in
real time to his PDA.
1.7.3. Handheld Systems:

Dept of CSE, Vemana I.T Page 24 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Handheld Systems include personal digital assistants (PDAs), such as Palm and Pocket-
PCs, and cellular telephones, many of which use special-purpose embedded operating
systems.
 Handheld devices have small amounts of memory, slow processors, and small display
screens.
 The amount of physical memory in a handheld depends on the device, but typically it is
somewhere between 1 MB and 1 GB.
 Handheld devices use smaller, slower processors that consume less power.
 Processors for most handheld devices run at a fraction of the speed of a processor in a PC.
Faster processors require more power.

 To include a faster processor in a handheld device would require a larger battery, which
would take up more space and would have to be replaced.
 Some handheld devices use wireless technology, such as Bluetooth or 802.11, allowing
remote access to e-mail and Web browsing. Cellular telephones with connectivity to the
Internet fall into this category.
 PDAs that do not provide wireless access, downloading data typically requires the user
first to download the data to a PC or workstation and then download the data to the PDA.
 Some PDAs allow data to be directly copied from one device to another using an infrared
link.
 The limitations in the functionality of PDAs are balanced by their convenience and
portability.

1.8. COMPUTING ENVIRONMENTS:


 Traditional Computing
 Client-Server Computing
 Peer-to-Peer Computing
 Web-Based Computing

1.8.1. Traditional Computing:

Dept of CSE, Vemana I.T Page 25 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Web technologies are stretching the boundaries of traditional computing.


 Companies establish portals, which provide Web accessibility to their internal servers.
Network computers are essentially terminals that understand Web-based computing.
 Handheld computers can synchronize with PCs to allow very portable use of con1pany
information.
 Handheld PDAs can also connect to wireless networks use the company's Web portal (as
well as the myriad other Web resources).
 At home, most users had a single computer with a slow modem connection to the office, the
Internet, or both.
 Some homes even have to protect their networks from security breaches.
 For a period of time, systems were either batch or interactive.
 Batch systems processed jobs in bulk, with predetermined input (from files or other
sources of data).
 Interactive systems waited for input from users. To optimize the use of the computing
resources, multiple users shared time on these systems.
 Time-sharing systems used a timer and scheduling algorithms to rapidly cycle processes
through the CPU, giving each user a share of the resources.
 User processes, and system processes that provide services to the user, are managed so
that each frequently gets a slice of computer time.

1.8.2. Client-Server Computing:


 A defined server provides services ( HW or SW ) to other systems which serve as clients.

(Technically clients and servers are processes, not HW, and may co-exist on the same
physical computer. )
 A process may act as both client and server of either the same or different resources.
 Served resources may include disk space, CPU cycles, time of day, IP name information,
graphical displays (X Servers), or other resources.

 The client-server system has the general structure shown in figure 1.12

Dept of CSE, Vemana I.T Page 26 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.12. General Structure of a Client-Server system.

 Server systems are broadly categorized as compute servers and file servers:
 The Compute-server system provides an interface to which a client can send a request
to perform an action (for example, read data); in response, the server executes the
action and sends back results to the client A server running a database that responds to
client requests for data is an example of such a system.
 The File-server system provides a file-system interface where clients can create,
update, read, and delete files. An example of such a system is a Web server that delivers
files to clients running Web browsers.

1.8.3. Peer-to-Peer Computing:


 In Peer-to-Peer, clients and servers are not distinguished from one another; instead, all
nodes within the system are considered peers, and each may act as either a client or a
server, depending on whether it is requesting or providing a service.
 In a client-server system, the server is a bottleneck; but in a peer-to-peer system, services
can be provided by several nodes distributed throughout the network.
 To participate in a peer-to-peer system, a node must first join the network of peers. Once a
node has joined the network, it can begin providing services to-and requesting services
from -other nodes in the network.

 Service availability is accomplished in one of two general ways:


 When a node joins a network, it registers its service with a centralized lookup service
on the network. Any node desiring a specific service first contacts this centralized
lookup service to determine which node provides the service. The remainder of the
communication takes place between the client and the service provider.

Dept of CSE, Vemana I.T Page 27 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 A peer acting as a client must first discover what node provides a desired service by
broadcasting a request for the service to all other nodes in the network. The node (or
nodes) providing that service responds to the peer making the request. To support
this approach, a discovery protocol must be provided that allows peers to discover
services provided by other peers in the network.

1.8.4. Web Based Computing:


 Web computing has increased the emphasis on networking. Devices that were not
previously networked now include wired or wireless access.
 Devices that were networked now have faster network connectivity, provided by either
improved networking technology optimized network implementation code, or both.
 The implementation of Web-based computing has given rise to new categories of devices,
such as load balancers, which distribute network connections an1.ong a pool of similar
servers.
 Operating systems like Windows 95 which acted as Web clients,/ have evolved into Linux
and Windows XP which can act as Web servers as well as clients.
 The Web has increased the complexity of devices because their users require them to be
Web-enabled.

1.9. OPERATING SYSTEM SERVICES:


 An OS provides services for the execution of the programs and the users of such programs.
The services provided by one OS may be different from other OS. OS makes the
programming task easier.

 Figure 1.13 shows the various operating system services.

Dept of CSE, Vemana I.T Page 28 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.13. A view of Operating System Services

 The common services provided by the OS are


 User Interface:- All operating systems have a user interface (UI).
This interface takes several forms.
 Command-line interface (CLI) – which uses text commands and methods for
entering.
 Batch Interface – in which commands and directives to control those commands
are entered into files, and those files are executed.
 Graphical User Interface – the interface is a window system with a pointing
device to direct I/O, choose from menus and make selections and keyboard to
enter text.
 Program Execution:- The OS must able to load the program into memory & run that
program. The program must end its execution either normally or abnormally.
 I/O Operation:- A program running may require any I/O. This I/O may be a file or
specific device users cannot control the I/O device directly so the OS must provide a
means for controlling I/O devices.
 File System Interface:- Program need to read or write a file. The OS should provide
permission for the creation or deletion of files by names.
 Communication:- In certain situation one process may need to exchange information
with another process. This communication May takes place in two ways.

Dept of CSE, Vemana I.T Page 29 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Between the processes executing on the same computer.


 Between the processes executing on different computer that are connected by a
network.
This communication can be implemented via shared memory or by OS.
 Error Detection:- Errors may occur in CPU, I/O devices or in memory Hardware. The
OS constantly needs to be aware of possible errors. For each type of errors the OS
should take appropriate actions to ensure correct & consistent computing.

 OS with multiple users provides the following services,


 Resource Allocation:- When multiple users logs onto the system or when multiple
jobs are running, resources must be allocated to each of them. The OS manages
different types of OS resources. Some resources may need some special allocation
codes & others may have some general request & release code.
 Accounting:- We need to keep track of which users use how many & what kind of
resources. This record keeping may be used for accounting. This accounting data may
be used for statistics or billing. It can also be used to improve system efficiency.
 Protection & Security:- Protection ensures that all the access to the system are
controlled. Security starts with each user having authenticated to the system, usually
by means of a password. External I/O devices must also be protected from invalid
access. In multi process environment it is possible that one process may interface with
the other or with the OS, so protection is required.

1.10. USER OPERATING SYSTEM INTERFACE:


 There are 2 fundamental approaches for users to interface with OS
 Command Interpreter (CI) that allows users to directly enter the commands that are
to be performed by the OS.
 Graphical User Interface (GUI) allows the user to interface with the OS.

1.10.1. Command Interpreter (CI):


 Command interpreter system between the user & the OS. It is a system program to the OS.
 Command interpreter is a special program in UNIX & MS DOS OS i.e. running when the user
logs on.

Dept of CSE, Vemana I.T Page 30 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Many commands are given to the OS through control statements when the user logs on, a
program that reads & interprets control statements is executed automatically. This
program is sometimes called the control card interpreter or command line interpreter and
is also called as shell.
 The command statements themselves deal with process creation & management, I/O
handling, secondary storage management, main memory management, file system access,
protection & Network.
 The CI itself contains the code to execute the command. For example, to delete a file may
cause the CI to jump to a section of its code that sets up the parameters and makes
appropriate system call.
 An alternative approach used in UNIX implements commands through system programs.
The UNIX command to delete a file: rm file.txt.

 Figure 1.14 shows the Bourne shell command interpreter being used on Solaris 10.

Figure 1.14. The Bourne shell command interpreter in Solaris 10.

Dept of CSE, Vemana I.T Page 31 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

1.10.2. Graphical User Interface (GUI):


 Rather than entering commands directly via a command-line interface, users employ a
mouse-based window and- menu system characterized by a metaphor.
 The user moves the mouse to position its pointer on images, or icons on the screen (the
desktop) that represent programs, files, directories, and system functions.
 Depending on the mouse pointer's location, clicking a button on the mouse can invoke a
program, select a file or directory-known as a folder-or pull down a menu that contains
commands.
 GUI appeared as a part in early 1970s at Xerox PARC research facility. The first GUI
appeared on the Xerox Alto computer in 1973.
 Graphical interfaces became more widespread with the advent of Apple Macintosh
computers in the 1980s.
 The user interface for the Macintosh operating system (Mac OS) being the adoption of the
Aqua interface that appeared with Mac OS X.
 Microsoft's first version of Windows-Version 1.0-was based on the addition of a GUI
interface to the MS-DOS operating system. Later versions of Windows with several
enhancements in its functionality, including Windows Explorer.

 In UNIX various GUI interfaces available including Common Desktop Environment (CDE), K
Desktop Environment (KDE) and GNOME desktop.
 Usually UNIX users prefer a Command line interface such as shell interfaces where as
Windows users prefer Windows GUI.

1.11. SYSTEM CALLS:


 System provides interface between the process & the OS.
 The calls are generally available as assembly language instruction & certain system allow
system calls to be made directly from a high level language program.
 Several languages have been defined to replace assembly language program.
 A system call instruction generates an interrupt and allows OS to gain control of the
processors.

Dept of CSE, Vemana I.T Page 32 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 System calls occur in different ways depending on the computer. Some time more
information is needed to identify the desired system call. The exact type & amount of
information needed may vary according to the particular OS & call.
 Mostly accessed by programs via a high-level Application Program Interface (API) rather
than direct system call use
 The API specifies a set of functions that are available to an application programmer,
including the parameters that are passed to each function and the return values the
programmer can expect.
 Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems
(including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java
virtual machine (JVM).

 System call sequence to copy the contents of one file to another file shown in figure 1.15

Figure 1.15. Example of how system calls are used.

Dept of CSE, Vemana I.T Page 33 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Example of Standard API


 Consider the Read File() function in the
 Win32 API—a function for reading from a file.

Figure 1.15. The API for the ReadFile () function

 A description of the parameters passed to ReadFile()


 HANDLE file—the file to be read
 LPVOID buffer—a buffer where the data will be read into and written from
 DWORD bytesToRead—the number of bytes to be read into the buffer
 LPDWORD bytesRead—the number of bytes read during the last read
 LPOVERLAPPED ovl—indicates if overlapped I/O is being used

 System Call Implementation


 Typically, a number associated with each system call. System-call interface maintains
a table indexed according to these numbers.
 The system call interface invokes intended system call in OS kernel and returns status
of the system call and any return values
 The caller need know nothing about how the system call is implemented. Just needs to
obey API and understand what OS will do as a result call. Most details of OS interface
hidden from programmer by API. Managed by run-time support library (set of
functions built into libraries included with compiler).

 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 1.16.

Dept of CSE, Vemana I.T Page 34 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

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

 System Call Parameter Passing


 Three general methods used to pass parameters to the OS
 Simplest: pass the parameters in registers.
In some cases, may be more parameters than registers
 Parameters stored in a block, or table, in memory, and address of block passed as
a parameter in a register.
This approach taken by Linux and Solaris.
 Parameters placed, or pushed, onto the stack by the program and popped off the
stack by the operating system
 Block and stack methods do not limit the number or length of parameters being
passed.

 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 addressed passed in register or on stack, as shown in Figure 1.17.

Dept of CSE, Vemana I.T Page 35 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.17. Passing of parameters as a table.

1.12. TYPES OF SYSTEM CALLS:


 System calls may be grouped roughly into 6 categories
1. Process control.
2. File manipulation / management.
3. Device manipulation / management.
4. Information maintenance.
5. Communication.
6. Protection

 Types of System calls are shown in Figure 1.18

 Examples of Windows and Unix System Calls is shown in Figure 1.19

Dept of CSE, Vemana I.T Page 36 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Process control
 end, abort
 load, execute
 create process, terminate process
 get process attributes, set process attributes
 wait for time
 wait event, signal event
 allocate and free memory
 File management
 create file, delete file
 open, close
 read, write, reposition
 get file attributes, set file attributes
 Device management
 request device, release device
 read, write, reposition
 get device attributes, set device attributes
 logically attach or detach devices
 Information maintenance
 get time or date, set time or date
 get system data, set system data
 get process, file, or device attributes
 set process, file, or device attributes
 Communications
 create, delete communication connection
 send, receive messages
 transfer status information
 attach or detach remote devices
 Protection
 Set permission, get permission
 Allow user, deny user

Figure 1.17. Passing of parameters as a table.

Dept of CSE, Vemana I.T Page 37 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.18. Examples of Windows and Unix System Calls

1. PROCESS CONTROL:
 A running program needs to be able to halt its execution either normally (end) or
abnormally (abort).
 If a system call is made to terminate the currently running program abnormally, or if the
program runs into a problem and causes an error trap, a dump of memory is sometimes
taken and an error message generated.
 The dump is written to disk and may be examined by debugger - a system program
designed to aid the programmer in finding and correcting bugs-to determine the cause of
the problem.

Dept of CSE, Vemana I.T Page 38 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 The operating system must transfer control to the command interpreter to read the next
command.
 In an interactive system, the command interpreter simply continues with the next
command; it is assumed that the user will issue an appropriate command to respond to
any error.
 In a GUI system, a pop-up window might alert the user to the error and ask for guidance.
 In a batch system, the command interpreter usually terminates the entire job and
continues with the next job.

 A Control card is a batch-system concept. It is a command to manage the execution of a


process. If the program discovers an error in its input and wants to terminate abnormally,
it may also want to define an error level.
 A process or job executing one program may want to load and execute another program.
This feature allows the command interpreter to execute a program as directed by, for
example, a user command, the click of a mouse, or a batch command.
 There are so many facts and variations in process and job control that we next use two
examples-one involving a single-tasking system and the other a multitasking system.
 The MS-DOS operating system is an example of a single-tasking system. It has a command
interpreter that is invoked when the computer is started (Figure 1.19(a)). Because MS-
DOS is single-tasking, it uses a simple method to run a program and does not create a new
process.
 It loads the program into memory, writing over most of itself to give the program as much
memory as possible (Figure 1.19(b)). Next, it sets them instruction pointer to the first
instruction of the program. The program then runs, and either an error cause a trap, or
the program executes a system call to terminate.
 FreeBSD is an example of multitasking (Figure 1.20). When a user logs on to the system,
the shell of the user`s choice is run.
 To start new process, the shell executes fork() system call, then loaded to memory via
exec() system call and the program is executed.

Dept of CSE, Vemana I.T Page 39 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.18. (a) At system startup (b) running a program

Figure 1.19. Free BSD running Multiple programs.

2. FILE MANAGEMENT:
 System calls can be used to create & deleting of files. System calls may require the name
of the files with attributes for creating & deleting of files.
 Other operation may involve the reading of the file, write & reposition the file after it is
opened.

Dept of CSE, Vemana I.T Page 40 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Finally we need to close the file.


 For directories some set of operation are to be performed. Sometimes we require
resetting some of the attributes on files & directories. The system call get file attribute &
set file attribute are used for this type of operation.

3. DEVICE MANAGEMENT:
 The system calls are also used for accessing devices.
 Many of the system calls used for files are also used for devices.
 In multi user environment the requirement are made to use the device. After using the
device must be released using release system call the device is free to be used by another
user. These functions are similar to open & close system calls of files.
 Read, write & reposition system calls may be used with devices.
 MS-DOS & UNIX merge the I/O devices & the files to form file services structure. In file
device structure I/O devices are identified by file names.

4. INFORMATION MAINTAINANCE:
 Many system calls are used to transfer information between user program & OS.
Example:- Most systems have the system calls to return the current time & date, number
of current users, version number of OS, amount of free memory or disk space & so on.
 In addition the OS keeps information about all its processes & there are system calls to
access this information.

5. COMMUNICATION:-
There are two modes of communication,
 Message Passing Models:-
 In this information is exchanged using inter-process communication facility provided by
OS.
 Before communication the connection should be opened.
 The name of the other communicating party should be known, it can be on the same
computer or it can be on another computer connected by a computer network.
 Each computer in a network may have a host name like IP name similarly each process
can have a process name which can be translated into equivalent identifier by OS.

Dept of CSE, Vemana I.T Page 41 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 The get host id & process id system call do this translation. These identifiers are then
passed to the open & close connection system calls.
 The recipient process must give its permission for communication to take place with an
accept connection call.
 Most processes receive the connection through special purpose system program
dedicated for that purpose called daemons. The daemon on the server side is called
server daemon & the daemon on the client side is called client daemon.

 Shared Memory:-
 In this the processes uses the map memory system calls to gain access to memory owned
by another process.
 The OS tries to prevent one process from accessing another process memory.
 In shared memory this restriction is eliminated and they exchange information by
reading and writing data in shared areas. These areas are located by these processes and
not under OS control.
 They should ensure that they are not writing to same memory area.
 Both these types are commonly used in OS and some even implement both.
 Message passing is useful when small number of data need to be exchanged since no
conflicts are to be avoided and it is easier to implement than in shared memory. Shared
memory allows maximum speed and convenience of communication as it is done at
memory speed when within a computer.

6. PROTECTION:
 Provides a mechanism for controlling access to the resources provided by a computer
system.
 Protection was a concern only on multiprogrammed computer systems with several
users.
 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.

Dept of CSE, Vemana I.T Page 42 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

1.13. SYSTEM PROGRAMS:


 System programs (system utilities) provide a convenient environment program
development & execution.
 System programs provide OS functionality through separate applications, which are not
part of the kernel or command interpreters. They are also known as system utilities or
system applications.
 Most systems also ship with useful applications such as calculators and simple editors, (e.g.
Notepad). Some debate arises as to the border between system and non-system
applications.

 System Programs can be divided into 5 categories:


 File management: These programs create, delete, copy, rename, print, dump, list, and
generally manipulate files and directories.
 Status information: Some programs ask the system for the date, time, amount of
available memory or disk space, number of users, or similar status information. Others
are more complex, providing detailed performance, logging, and debugging information.
Some systems also support a Registry which is used to store and retrieve configuration
information.
 File modification. Several text editors may be available to create and modify the
content of files stored on disk or other storage devices. There may also be special
commands to search contents of files or perform transformations of the text.
 Programming-language support: Compilers, assemblers, debuggers, and interpreters
for common programming languages (such as C, C++, Java, Visual Basic, and PERL) are
often provided to the user with the operating system.
 Program loading and execution: Once a program is assembled or compiled, it must be
loaded into memory to be executed. The system may provide absolute loaders,
relocatable loaders, linkage editors, and overlay loaders. Debugging systems for either
higher-level languages or machine language are needed as well.
 Communications: These programs provide the mechanism for creating virtual
connections among processes, users, and computer systems. They allow users to send
messages to one another's screens, to browse Web pages, to send electronic-mail
messages, to log in remotely, or to transfer files from one machine to another.

Dept of CSE, Vemana I.T Page 43 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 In addition to systems programs, operating systems are supplied with programs that are
useful in solving common problems or performing common operations. Such application
programs include web browsers, word processors and text formatters, spreadsheets,
database systems, compilers, plotting & statistical-analysis packages and games.

1.14. OPERATING SYSTEM DESIGN AND IMPLEMENTATION:


1.14.1. Design Goals:
 Problem in designing a system is to define goals and specification.
 At the highest level, the design of the system will be affected by the choice of hardware and
the type of system: batch, time shared, single user, multiuser, distributed, real time or
general purpose.
 Design and Implementation of OS not “solvable”, but some approaches have proven
successful

 The requirements can be divided into two basic groups


 User goals
 System goals
 User goals – operating system should be convenient to use, easy to learn, reliable, safe, and
fast.
 System goals – operating system should be easy to design, implement, and maintain, as
well as flexible, reliable, error-free, and efficient.

1.14.2. Mechanisms and Policies:


 Important principle to separate
Policy: What will be done?
Mechanism: How to do it?
 Mechanisms determine how to do something, policies decide what will be done
 The separation of policy from mechanism is a very important principle, it allows maximum
flexibility if policy decisions are to be changed later.
 Micro kernel based OS take the separation of mechanism and policy by implementing a
basic set of building blocks.
 These blocks are policy free, allowing more advanced mechanisms and policies to be added
via user created kernel modules or via user programs.
 Policy decisions are important for all resource allocation.

Dept of CSE, Vemana I.T Page 44 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

1.14.3. Implementation:
 Operating systems have been written in assembly language, now OS have been written in
high level languages such as C or C++.
 The advantage of using high level language is that the code can be written faster, more
compact & easier to understand and debug.
 Improvements in compiler technology will improve the generated code for the OS by
simple recompilation.
 OS is easier to port – to move to some other hardware – if it is written in high level
language.
 The disadvantage of implementing OS in high level language is reduced speed and
increased storage requirements.
 Performance improvements in OS results in better data structure & algorithms.
 After OS is written, bottleneck routines can be identified and can be replaced with assembly
language code.

1.15. OPERATING SYSTEM STRUCTURE:


 A modern OS is large & complex, a common approach is to partition the task into small
components rather than have one monolithic system.

1.15.1. Simple Structure:


 Simple structure OS are small, simple & limited systems.
 The structure is not well defined
 MS-DOS is an example of simple structure OS.
 When DOS was originally written its developers had no idea how big and important it
would eventually become.
 It was written by a few programmers in a relatively short amount of time, without the
benefit of modern software engineering techniques, and then gradually grew over time to
exceed its original expectations.
 It does not break the system into subsystems, and has no distinction between user and
kernel modes, allowing all programs direct access to the underlying hardware. (Note that
user versus kernel mode was not supported by the 8088 chip set anyway, so that really
wasn't an option back then.)

Dept of CSE, Vemana I.T Page 45 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.20. MS-DOS layer Structure

 UNIX consisted of two separate modules


a. Kernel
b. The system programs.
 Kernel is further separated into series of interfaces & device drivers which were added &
expanded as the UNIX evolved over years.
 The kernel also provides the CPU scheduling, file system, m/y management & other OS
function through system calls.
 System calls define API to UNIX and system programs commonly available define the user
interface. The programmer and the user interface determine the context that the kernel
must support.
 New versions of UNIX are designed to support more advanced H/w. the OS can be broken
down into large number of smaller components which are more appropriate than the
original MS-DOS.

 The original UNIX OS used a simple layered approach, but almost all the OS was in one big
layer, not really breaking the OS down into layered subsystems:

Dept of CSE, Vemana I.T Page 46 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.21. Unix System Structure

1.15.2. Layered Approach:


 Another approach is to break the OS into a number of smaller layers, each of which rests on
the layer below it, and relies solely on the services provided by the next lower layer.
 This approach allows each layer to be developed and debugged independently, with the
assumption that all lower layers have already been debugged and are trusted to deliver
proper services.

 The operating system is divided into a number of layers (levels), each built on top of lower
layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user
interface (figure 1.22).

 The main advantage of layered approach is the modularity i.e. each layer uses the services
& functions provided by the lower layer. This approach simplifies the debugging &
verification.
 With modularity, layers are selected such that each uses functions (operations) and
services of only lower-level layers.

Dept of CSE, Vemana I.T Page 47 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.22. A layered Operating System

 The problem is deciding what order in which to place the layers, as no layer can call upon
the services of any higher layer, and so many chicken-and-egg situations may arise.
 Layered approaches can also be less efficient, as a request for service from a higher layer
has to filter through all lower layers before it reaches the HW, possibly with significant
processing at each step.

1.15.3. Microkernels:
 The basic idea behind micro kernels is to remove all non-essential services from the kernel,
and implement them as system applications instead, thereby making the kernel as small
and efficient as possible.
 Micro kernel is a small OS which provides the foundation for modular extensions.
 The main function of the micro kernels is to provide communication facilities between the
current program and various services that are running in user space.
 Most Microkernels provide basic process and memory management, and message passing
between other services, and not much more.
 Mach was the first and most widely known microkernel, and now forms a major component
of Mac OSX.
 Benefits:

Dept of CSE, Vemana I.T Page 48 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Easier to extend a microkernel


 Easier to port the operating system to new architectures
 More reliable (less code is running in kernel mode)
 More secure

 Detriments:
 Performance overhead of user space to kernel space communication

Figure 1.23. Mac OS X Structure

1.15.4. Modules:
 The Modern OS development is object-oriented, with a relatively small core kernel and a set
of modules which can be linked in dynamically. See for example the Solaris structure, as
shown in Figure 1.24 below.
 Modules are similar to layers in that each subsystem has clearly defined tasks and
interfaces, but any module is free to contact any other module, eliminating the problems of
going through multiple intermediary layers, as well as the chicken-and-egg problems.
 The kernel is relatively small in this architecture, similar to Microkernels, but the kernel
does not have to implement message passing since modules are free to contact each other
directly.

Dept of CSE, Vemana I.T Page 49 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.24. Solaris Loadable Modules

 Most modern operating systems implement kernel modules


 Uses object-oriented approach.
 Each core component is separate.
 Each talks to the others over known interfaces.
 Each is loadable as needed within the kernel.
 Overall, similar to layers but with more flexible.

1.16. VIRTUAL MACHINES:


 A virtual machine takes the layered approach to its logical conclusion. It treats hardware
and the operating system kernel as though they were all hardware.
 The concept of a virtual machine is to provide an interface that looks like independent
hardware, to multiple different OS running simultaneously on the same physical hardware.
Each OS believes that it has access to and control over its own CPU, RAM, I/O devices, hard
drives, etc.
 A virtual machine provides an interface identical to the underlying bare hardware
 The operating system host creates the illusion that a process has its own processor and
(virtual memory)
 Each guest provided with a (virtual) copy of underlying computer.
 One obvious use for this system is for the development and testing of software that must
run on multiple platforms and/or OS.

Dept of CSE, Vemana I.T Page 50 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 One obvious difficulty involves the sharing of hard drives, which are generally partitioned
into separate smaller virtual disks for each operating OS.

Figure 1.25. System Models (a) Non Virtual Machines (b) Virtual Machines

1.16.1. History and Benefits


 Virtual machines first appeared as the VM Operating System for IBM mainframes in 1972
 Fundamentally, multiple execution environments (different operating systems) can share
the same hardware.
 Protect from each other.
 Each OS runs independently of all the others, offering protection and security benefits.
 Virtual machines are a very useful tool for OS development, as they allow a user full access
to and control over a virtual machine, without affecting other users operating the real
machine.
 Some sharing of file can be permitted, controlled.
 Commutate with each other, other physical systems via networking.
 Useful for development, testing.
 Consolidation of many low-resource use systems onto fewer busier systems.
 “Open Virtual Machine Format”, standard format of virtual machines, allows a VM to run
within many different virtual machine (host) platforms.

Dept of CSE, Vemana I.T Page 51 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

1.16.2. Simulation:
 An alternative to creating an entire virtual machine is to simply run an emulator, which
allows a program written for one OS to run on a different OS.
 For example, a UNIX machine may run a DOS emulator in order to run DOS programs, or
vice-versa.
 Emulators tend to run considerably slower than the native OS, and are also generally less
than perfect.

1.16.2. Para-Visualization:
 Para-virtualization is another variation on the theme, in which an environment is provided
for the guest program that is similar to its native OS, without trying to completely mimic it.
 Guest programs must also be modified to run on the Para-virtual OS.
 Solaris 10 uses a zone system, in which the low-level hardware is not virtualized, but the
OS and its devices (device drivers) are.
 Within a zone, processes have the view of an isolated system, in which only the
processes and resources within that zone are seen to exist.
 Figure 1.26 shows a Solaris system with the normal "global" operating space as well as
two additional zones running on a small virtualization layer.

Figure 1.26. System Models (a) Non Virtual Machines (b) Virtual Machines

Dept of CSE, Vemana I.T Page 52 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

1.16.3. Implementation:
 Implementation may be challenging, partially due to the consequences of user versus
kernel mode.
 Each of the simultaneously running kernels needs to operate in kernel mode at some
point, but the virtual machine actually runs in user mode.
 So the kernel mode has to be simulated for each of the loaded OS, and kernel system
calls passed through the virtual machine into a true kernel mode for eventual HW
access.
 The virtual machines may run slower, due to the increased levels of code between
applications and the HW, or they may run faster, due to the benefits of caching. ( And
virtual devices may also be faster than real devices, such as RAM disks which are faster
than physical disks.)

1.16.4. Examples:
1.16.4.1. VMware:
 Runs as an application on host operating system such as windows or Linux and allows
this host operating system to concurrently run several operating systems as independent
virtual machines.
 The 80x86 hardware platform, allowing simultaneous operation of multiple Windows and
Linux OS, as shown by example in Figure 1.27.
 The programmer could test the application on a host operating system and on three guest
operating systems with each system running as a separate virtual machine.
 In figure, Linux is the running as the host operating system; FreeBSD, Windows NT and
windows XP are running as the guest operating system.

Dept of CSE, Vemana I.T Page 53 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.27. VMware architecture

1.16.4.2. Java Virtual Machine (JVM):


 Java was designed from the beginning to be platform independent, by running Java only on
a Java Virtual Machine, JVM, of which different implementations have been developed for
numerous different underlying Hardware platforms.
 Java source code is compiled into Java byte code in .class files. Java byte code is binary
instructions that will run on the JVM as shown in Figure 1.28.
 The JVM implements memory management and garbage collection.
 Java byte code may be interpreted as it runs, or compiled to native system binary code
using just-in-time (JIT) compilation. Under this scheme, the first time that a piece of Java
byte code is encountered; it is compiled to the appropriate native machine binary code by
the Java interpreter. This native binary code is then cached; so that the next time that piece
of code is encountered it can be used directly.
 Some hardware chips have been developed to run Java byte code directly, which is an
interesting application of a real machine being developed to emulate the services of a
virtual one!

Dept of CSE, Vemana I.T Page 54 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.28. The Java Virtual Machine (JVM)

THE .NET FRAMEWORK:


 The .NET framework also relies on the concept of compiling code for an intermediary
virtual machine, (Common Language Runtime, CLR), and then using JIT compilation and
caching to run the programs on specific hardware.
 The .NET Framework is a collection of technologies, including a set of class libraries, and an
execution environment that come together to provide a platform for developing software.
This platform allows programs to be written to target the .NET Framework instead of a
specific architecture.
 A program written for the .NET Framework need not worry about the specifics of the
hardware or the operating system on which it will run. Thus, any architecture
implementing .NET will be able to successfully execute the program.
 At the core of the .NET Framework is the Common Language Runtime (CLR). The CLR is the
implementation of the .NET virtual machine. It provides an environment for execution of
programs written in any of the languages targeted at the .NET Framework.
 Programs written in languages such as C# (pronounced C-sharp) and VB.NET are compiled
into an intermediate, architecture-independent language called Microsoft Intermediate
Language (MS-IL). These compiled files, called assemblies, include MS-IL instructions and
metadata.
 The architecture of the CLR for the .NET framework is shown in Figure 1.29.

Dept of CSE, Vemana I.T Page 55 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

Figure 1.29. The architecture of the CLR for the .NET framework

1.17. OPERATING SYSTEM GENERATION:


 Operating systems are designed to run on any of a class of machines; the system must be
configured for each specific computer site.
 SYSGEN program obtains information concerning the specific configuration of the
hardware system
 Booting – starting a computer by loading the kernel
 Bootstrap program – code stored in ROM that is able to locate the kernel, load it into
memory, and start its execution

 OS may be designed and built for a specific HW configuration at a specific site, but more
commonly they are designed with a number of variable parameters and components, which
are then configured for a particular operating environment.
 Systems sometimes need to be re-configured after the initial installation, to add additional
resources, capabilities, or to tune performance, logging, or security.

Dept of CSE, Vemana I.T Page 56 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

 Information that is needed to configure an OS include:


 What CPU(s) are installed on the system, and what optional characteristics does each
have?
 How much RAM is installed? (This may be determined automatically, either at install or
boot time. )
 What devices are present? The OS needs to determine which device drivers to include, as
well as some device-specific characteristics and parameters.
 What OS options are desired, and what values to set for particular OS parameters. The
latter may include the size of the open file table, the number of buffers to use, process
scheduling (priority) parameters, disk scheduling algorithms, number of slots in the
process table, etc.
 At one extreme the OS source code can be edited, re-compiled, and linked into a new kernel.
 More commonly configuration tables determine which modules to link into the new kernel,
and what values to set for some key important parameters. This approach may require the
configuration of complicated make files, which can be done either automatically or through
interactive configuration programs; then make is used to actually generate the new kernel
specified by the new parameters.
 At the other extreme a system configuration may be entirely defined by table data, in which
case the "rebuilding" of the system merely requires editing data tables.
 Once a system has been regenerated, it is usually required to reboot the system to activate
the new kernel. Because there are possibilities for errors, most systems provide some
mechanism for booting to older or alternate kernels.
.
1.18. SYSTEM BOOT:
 Operating system must be made available to hardware so hardware can start it.
 Small piece of code – bootstrap loader, locates the kernel, loads it into memory, and starts
it. Sometimes two-step process where boot block at fixed location loads bootstrap loader
 When power initialized on system, execution starts at a fixed memory location. Firmware
used to hold initial boot code.
 When the system powers up, an interrupt is generated which loads a memory address into
the program counter, and the system begins executing instructions found at that address.

Dept of CSE, Vemana I.T Page 57 of 58


Operating System Unit – 1 - Introduction to Operating Systems, System structures

This address points to the "bootstrap" program located in ROM chips (or EPROM chips ) on
the motherboard.
 The ROM bootstrap program first runs hardware checks, determining what physical
resources are present and doing power-on self tests (POST) of all HW for which this is
applicable. Some devices, such as controller cards may have their own on-board
diagnostics, which are called by the ROM bootstrap program.
 The user generally has the option of pressing a special key during the POST process, which
will launch the ROM BIOS configuration utility if pressed. This utility allows the user to
specify and configure certain hardware parameters as where to look for an OS and whether
or not to restrict access to the utility with a password.
 Some hardware may also provide access to additional configuration setup programs,
such as for a RAID disk controller or some special graphics or networking cards.
 During boot up, depending on configuration, it may look for a floppy drive, CD ROM drive,
or primary or secondary hard drives, in the order specified by the HW configuration utility.
 Assuming it goes to a hard drive, it will find the first sector on the hard drive and load up
the fdisk table, which contains information about how the physical hard drive is divided up
into logical partitions, where each partition starts and ends, and which partition is the
"active" partition used for booting the system.
 For a single-boot system, the boot program loaded off of the hard disk will then proceed to
locate the kernel on the hard drive, load the kernel into memory, and then transfer control
over to the kernel.
 For dual-boot or multiple-boot systems, the boot program will give the user an
opportunity to specify a particular OS to load, with a default choice if the user does not pick
a particular OS within a given time frame.
 The boot program then finds the boot loader for the chosen single-boot OS, and runs that
program.
 When the system enters full multi-user multi-tasking mode, it examines configuration files
to determine which system services are to be started, and launches each of them in turn. It
then spawns login programs (gettys) on each of the login devices which have been
configured to enable user logins.
 GRUB is an example of an open source bootstrap program for Linux systems.
 A disk that has a boot block is called boot disk or system disk.

Dept of CSE, Vemana I.T Page 58 of 58

You might also like