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

FOS Module1

This document provides an introduction to operating systems, detailing their role in managing computer hardware and acting as intermediaries between users and hardware. It outlines the components of a computer system, the functions of operating systems, and different system architectures including single processor, multiprocessor, and clustered systems. The document also discusses user and system views of operating systems, resource allocation, and the importance of I/O structures and storage systems.

Uploaded by

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

FOS Module1

This document provides an introduction to operating systems, detailing their role in managing computer hardware and acting as intermediaries between users and hardware. It outlines the components of a computer system, the functions of operating systems, and different system architectures including single processor, multiprocessor, and clustered systems. The document also discusses user and system views of operating systems, resource allocation, and the importance of I/O structures and storage systems.

Uploaded by

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

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.

Fig 1.1: Components of Computer System

Dept of ISE, Vemana I.T Page 1 of 35


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

▪ 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 ISE, Vemana I.T Page 2 of 35


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 ISE, Vemana I.T Page 3 of 35


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 ISE, Vemana I.T Page 4 of 35


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 ISE, Vemana I.T Page 5 of 35


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 ISE, Vemana I.T Page 6 of 35


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 ISE, Vemana I.T Page 7 of 35


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 ISE, Vemana I.T Page 8 of 35


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 ISE, Vemana I.T Page 9 of 35


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 ISE, Vemana I.T Page 10 of 35


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 ISE, Vemana I.T Page 11 of 35


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 ISE, Vemana I.T Page 12 of 35


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 ISE, Vemana I.T Page 13 of 35


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 ISE, Vemana I.T Page 14 of 35


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 ISE, Vemana I.T Page 15 of 35


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 ISE, Vemana I.T Page 16 of 35


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 ISE, Vemana I.T Page 17 of 35


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 ISE, Vemana I.T Page 18 of 35


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 ISE, Vemana I.T Page 19 of 35


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 ISE, Vemana I.T Page 20 of 35


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:


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

Dept of ISE, Vemana I.T Page 21 of 35


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

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

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

Dept of ISE, Vemana I.T Page 22 of 35


Operating System Unit – 1 - Introduction to Operating Systems, System structures
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.

▪ 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.8. 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.

Dept of ISE, Vemana I.T Page 23 of 35


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

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

➢ 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 ISE, Vemana I.T Page 24 of 35


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

1.8.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.9. 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 ISE, Vemana I.T Page 25 of 35


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 ISE, Vemana I.T Page 26 of 35


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 ISE, Vemana I.T Page 27 of 35


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 ISE, Vemana I.T Page 28 of 35


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

Figure 1.17. Passing of parameters as a table.

1.10. 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 ISE, Vemana I.T Page 29 of 35


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 ISE, Vemana I.T Page 30 of 35


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 ISE, Vemana I.T Page 31 of 35


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 ISE, Vemana I.T Page 32 of 35


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 ISE, Vemana I.T Page 33 of 35


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 ISE, Vemana I.T Page 34 of 35


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 ISE, Vemana I.T Page 35 of 35

You might also like