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

1

UNIT I OPERATING SYSTEMS OVERVIEW

Computer System - Elements and organization; Operating System Overview - Objectives


and Functions - Evolution of Operating System; Operating System Structures – Operating
System Services - User Operating System Interface - System Calls – System Programs -
Design and Implementation - Structuring methods.

Sl.no Table of contents Page number


1. Computer System Overview 2
a. Elements 2
b. Computer system organisation 4
2. Operating system overview 9
a. Objectives and functions 9
b. Evolution of Operating System 12

3. Operating System Structures 18


4. Operating System Services 25
5. User Operating System Interface 27
6. System Calls 30
7. System Programs 37
8. OS Design and Implementation 39

9. Structuring methods 18
2

Computer system overview

 Elements
 Organization

Elements
 At a top level, a computer consists of,
1. Processor
2. memory and
3. I/O components.
 These components are interconnected in some fashion to achieve the main function
of the computer, which is to execute programs.
 Thus, there are 4 main structural elements:
1. Processor
2. Main Memory
3. I/O modules
4. System bus

1. Processor:
a. It controls the operation of a computer and performs its data processing
functions.
b. When there is only one processor, it is referred to as Central Processing
Unit. (CPU).
2. Main Memory:
a. Stores data and programs.
b. It is volatile. ie, the contents of the memory are lost, when the computer is
shut down.
c. Also referred to as real memory or primary memory.
3. I/O modules:
a. Move data between the computer and external environment.
b. External environment consists of variety of devices including,
i. Secondary memory devices (eg.disks)
ii. Communication equipment & terminals
4. System bus:
a. Provides for communication among
i. Processors
ii. main memory and
iii. I/O modules.
3

 Figure 1.1 depicts these top-level components.


 One of the processor’s functions is to exchange data with memory.
 For this purpose, it typically makes use of two internal (to the processor) registers:
b. Memory address register (MAR) - which specifies the address in memory
for the next read or write;
c. Memory buffer register (MBR) - which contains the data to be written into
memory or which receives the data read from memory.
 Similarly, an I/O address register (I/OAR) specifies a particular I/O device.
 An I/O buffer register (I/OBR) is used for the exchange of data between an I/O
module and the processor.
 A memory module consists of a set of locations, defined by sequentially numbered
addresses.
 Each location contains a bit pattern that can be interpreted as either an instruction
or data.
 An I/O module transfers data from external devices to processor and memory, and
vice versa. It contains internal buffers for temporarily holding data until they can be
sent on.
4

Computer System Organization

 Computer-system operation
 Storage structure
 I/O structure

 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).
 Each device controller is in charge of a specific type of device (for example,
disk drives, audio devices, or video displays).
 The CPU and the device controllers can execute in parallel, competing for
memory cycles.

 Bootstrap program
 System processes
 Interrupt

Bootstrap program:
o For a computer to start running—for instance, when it is powered up or
rebooted—it needs to have an initial program to run.
o This initial program, or bootstrap program, tends to be simple.
5

o It is stored within the computer hardware in read-only memory (ROM) or


electrically erasable programmable read-only memory (EEPROM), known
by the general term firmware.
o It initializes all aspects of the system, from CPU registers to device
controllers to memory contents.
o The bootstrap program must know,
 how to load the operating system
 how to start executing that system.
o To accomplish this goal, the bootstrap program must locate the operating-
system kernel and load it into memory.

System processes:
o Once the kernel is loaded and executing, it can start providing services to
the system and its users.
o Some services are provided outside of the kernel, by system programs that
are loaded into memory at boot time to become system processes, or
system daemons that run the entire time the kernel is running.

Interrupt:
o The occurrence of an event is usually signalled by an interrupt from either
the hardware or the software.
o Hardware may trigger an interrupt at any time by sending a signal to the
CPU, usually by way of the system bus.
o Software may trigger an interrupt by executing a special operation called a
system call (also called a monitor call).

 Storage structure:
 Main memory:
o General-purpose computers run most of their programs from rewritable
memory, called main memory (also called random-access memory, or
RAM).
 DRAM:
o Main memory commonly is implemented in a semiconductor
technology called dynamic random-access memory (DRAM).

 ROM:
o ROM cannot be changed, only static programs, such as the bootstrap
program are stored there.
 EEPROM:
6

o EEPROM can be changed but cannot be changed frequently and so


contains mostly static programs. For example, smart phones have
EEPROM to store their factory-installed programs.

 Drawbacks of main memory:


o Main memory is usually too small to store all needed programs and data
permanently.
o Main memory is a volatile storage device that loses its contents when
power is turned off or otherwise lost.
 Secondary storage:
o Most computer systems provide secondary storage as an extension of
main memory.
o The main requirement for secondary storage is that it be able to hold
large quantities of data permanently.
o The most common secondary-storage device is a magnetic disk, which
provides storage for both programs and data.
o Others include cache memory, CD-ROM, magnetic tapes, and so on.
 Storage-device hierarchy:
o The wide variety of storage systems can be organized in a hierarchy
(Figure 1.4) according to speed and cost.
o The higher levels are expensive, but they are fast.
o As we move down the hierarchy, the cost per bit generally decreases,
whereas the access time generally increases.
o The top four levels of memory in Figure 1.4 may be constructed using
semiconductor memory.
7

o Volatile storage loses its contents when the power to the device is
removed.
o In the absence of expensive battery and generator backup systems, data
must be written to non-volatile storage for safekeeping.

 I/O structure:
 Storage is only one of many types of I/O devices within a computer.
 A general-purpose computer system consists of CPUs and multiple device
controllers that are connected through a common bus.
 Each device controller is in charge of a specific type of device.
 Depending on the controller, more than one device may be attached.
 For instance, seven or more devices can be attached to the small computer-
systems interface (SCSI) controller.
 A device controller maintains some local buffer storage and a set of special-
purpose registers.
 The device controller is responsible for moving the data between the peripheral
devices that it controls and its local buffer storage.
 Typically, operating systems have a device driver for each device controller.
 This device driver understands the device controller and provides the rest of the
operating system with a uniform interface to the device.
8

 Direct memory access (DMA):


o When the processor wishes to read or write a block of data, it issues a
command to the DMA module, by sending to the DMA module the
following information:
 Whether a read or write is requested
 The address of the I/O device involved
 The starting location in memory to read data from or write data to
 The number of words to be read or written

o When the transfer is complete, the DMA module sends an interrupt signal to
the processor.
o Thus, the processor is involved only at the beginning and end of the
transfer.
 Figure 1.5 shows the interplay of all components of a computer system.
9

Operating system overview


 Objectives and functions
 Evolution of Operating System

Operating system objectives and functions


An OS is a program that controls the execution of application programs and acts as
an interface between applications and the computer hardware.

Three objectives of OS:


1. Convenience:
An OS makes a computer more convenient to use.
2. Efficiency:
An OS allows the computer system resources to be used in an efficient
manner.
3. Ability to evolve:
An OS should be constructed in such a way as to permit the effective,
i. Development
ii. Testing
iii. Introduction of new system functions.

 The Operating System as a User/Computer Interface


 The Operating System as Resource Manager

 The Operating System as a User/Computer Interface


 The hardware and software used in providing applications to a user can be viewed
in a layered or hierarchical fashion, as depicted in Figure 2.1 .
 The user of those applications, the end user, generally is not concerned with the
details of computer hardware.
 An application can be expressed in a programming language and is developed by
an application programmer.
 Utilities, or library programs:
 If one were to develop an application program as a set of machine instructions
that is completely responsible for controlling the computer hardware, a set of
system programs is provided called utilities.
 The most important collection of system programs comprises the OS. The OS
masks the details of the hardware from the programmer and provides the
programmer with a convenient interface for using the system. It acts as mediator,
10

making it easier for the programmer and for application programs to access and use
those facilities and services.

 The Operating System as Resource Manager


o A computer is a set of resources for the movement, storage, and processing
of data and for the control of these functions.
o The OS is responsible for managing these resources.
o Like other computer programs, the OS provides instructions for the
processor.
o Figure 2.2 suggests the main resources that are managed by the OS.
o A portion of the OS is in main memory.
o This includes the kernel , or nucleus , which contains the most frequently
used functions in the OS and, at a given time, other portions of the OS
currently in use.
o The remainder of main memory contains user programs and data.
o The memory management hardware in the processor and the OS jointly
control the allocation of main memory.
o The OS decides when an I/O device can be used by a program in execution
and controls access to and use of files.
o The processor itself is a resource, and the OS must determine how much
processor time is to be devoted to the execution of a particular user
program.
11
12

Evolution of OS
 Serial processing
 Simple batch systems
 Multiprogrammed batch systems
 Time-sharing systems

 Serial processing:
 From the late 1940s to the mid-1950s.
 Users have access to the computer in series.
 The programmer interacted directly with the computer hardware;
 There was no OS.
 Input:
o Programs in machine code were loaded via the input device (e.g., a card
reader).
 In case of error:
o If an error halted the program, the error condition was indicated by the
lights.
 Output:
o If the program proceeded to a normal completion, the output appeared
on the printer.

Two main problems:


o Scheduling
o Setup time

Scheduling:
 Most installations used a hardcopy sign-up sheet to reserve
computer time.
 A user might sign up for an hour and finish in 45 minutes.
 A user might not finish in the allotted time and forced to stop.

Setup time:
 A considerable amount of time was spent just in setting up the program
to run.

 Simple batch systems:


 Developed in mid 1950’s.
 The central idea behind the simple batch-processing scheme is the use of a
piece of software known as the monitor.
 With this type of OS, the user no longer has direct access to the processor.
13

 Instead, the user submits the job on cards or tape to a computer operator, who
batches the jobs together sequentially and places the entire batch on an input
device, for use by the monitor.
 Each program is constructed to branch back to the monitor when it completes
processing, at which point the monitor automatically begins loading the next
program.

2 views:
1. Monitor point of view
2. Processor point of view

Monitor point of view:


o The monitor controls the sequence of events.
o For this to be so, much of the monitor must always be in main memory and
available for execution (Figure 2.3). That portion is referred to as the
resident monitor.

o The rest of the monitor consists of utilities and common functions that are
loaded as subroutines to the user program.
o The monitor reads in jobs one at a time from the input device (typically a card
reader or magnetic tape drive).
o As it is read in, the current job is placed in the user program area, and control is
passed to this job.
14

o When the job is completed, it returns control to the monitor, which immediately
reads in the next job.
o The results of each job are sent to an output device, such as a printer, for
delivery to the user.

Processor point of view:


o At a certain point, the processor is executing instructions from the portion of
main memory containing the monitor.
o These instructions cause the next job to be read into another portion of main
memory.
o Once a job has been read in, the processor will encounter a branch instruction in
the monitor that instructs the processor to continue execution at the start of the
user program.
o The processor will then execute the instructions in the user program until it
encounters an ending or error condition.
o Either event causes the processor to fetch its next instruction from the monitor
program.
o Thus the phrase ―control is passed to a job‖ simply means that the processor is
now fetching and executing instructions in a user program, and ―control is
returned to the monitor‖ means that the processor is now fetching and executing
instructions from the monitor program.

 Certain other hardware features are also desirable:


1. Memory protection
2. Timer
3. Privileged instructions
4. Interrupts

Memory protection:
- While the user program is executing, it must not alter the memory
area containing the monitor.
- If such an attempt is made, the processor hardware should detect an
error and transfer control to the monitor.

Timer:
- The timer is set at the beginning of each job.
- If the timer expires, the user program is stopped, and control returns
to the monitor.
15

Privileged instructions:
- Certain machine level instructions are designated privileged and can
be executed only by the monitor.
- If the processor encounters such an instruction while executing a
user program, an error occurs causing control to be transferred to the
monitor.

Interrupts:
- This feature gives the OS more flexibility in relinquishing control to
and regaining control from user programs.

2 modes:
1. User mode
2. Kernel mode

User mode:
- A user program executes in a user mode, in which certain areas of
memory are protected from the user’s use and in which certain
instructions may not be executed.

Kernel mode:
- The monitor executes in a system mode, or what has come to be
called kernel mode, in which privileged instructions may be
executed and in which protected areas of memory may be accessed.

Merit of simple batch system:


- Improves utilization of computer.

Demerit of simple batch system:


- Some main memory is now given over to the monitor.
- Some processor time is consumed by the monitor.

 Multiprogrammed batch systems:


 When we have a single program, referred to as uniprogramming.
 The processor spends a certain amount of time executing, until it reaches an
I/O instruction.
16

 It must then wait until that I/O instruction concludes before proceeding.
 When one job needs to wait for I/O, the processor can switch to the other job,
which is likely not waiting for I/O ( Figure 2.5b ).
 We might expand memory to hold three, four, or more programs and switch
among all of them ( Figure 2.5c ). The approach is known as
multiprogramming , or multitasking . It is the central theme of modern
operating systems.
Merit
 The most notable additional feature is the hardware that supports I/O interrupts and
DMA (direct memory access).
Demerit:
 Requires some form of memory management.
 Requires an algorithm for scheduling.
17

 Time-sharing systems:
 Just as multiprogramming allows the processor to handle multiple batch jobs at
a time, multiprogramming can also be used to handle multiple interactive jobs.
 In this latter case, the technique is referred to as time sharing , because
processor time is shared among multiple users.
 In a time-sharing system, multiple users simultaneously access the system
through terminals, with the OS interleaving the execution of each user program
in a short burst or quantum of computation.
 Both batch processing and time sharing use multiprogramming. The key
differences are listed in Table 2.3 .
18

Operating system-structure
OR
Structuring methods
 An operating system provides the environment within which programs are
executed.
 A common approach is to partition the task into small components, or modules,
rather than have one single system.

(the users)

shells and commands


compilers and interpreters
system libraries
system-call interface to the kernel

signals terminal file system CPU scheduling


handling swapping block I/O page replacement
kernel

character I/O system system demand paging


terminal drivers disk and tape drivers virtual memory

kernel interface to the hardware

terminal controllers device controllers memory controllers


terminals disks and tapes physical memory

Figure 2.12 Traditional UNIX system structure.

Monolithic Structure

 The simplest structure for organizing an operating system is no structure


at all.
 This approach — known as a monolithic structure— is a common
technique for designing operating systems.
 Disadvantage: they are difficult to implement and extend.
 Advantage: there is very little overhead in the system-call interface, and
communication within the kernel is fast.
19

Layered Approach
 a system is divided into separate, smaller components that have specific and
limited func- tionality.
 All these components together comprise the kernel.
 The advantage of this modular approach is that changes in one component
affect only that component.
 layered approach,
o operating system is broken into a number of layers (levels).
o The bottom layer (layer 0) is the hardware;
o the highest (layer N) is the user interface.
o This layering structure is depicted in Figure 2.14.
o The main advantage of the layered approach is simplicity of
construction and debugging.
20

 Each layer is implemented only with operations provided by lower-level


layers.
 A layer does not need to know how these operations are implemented; it
needs to know only what these operations do.

Microkernels
 structures the operating system by removing all nonessential components
from the kernel and implementing them as user- level programs that
reside in separate address spaces.
 The result is a smaller kernel.

 The main function of the microkernel is to provide communication between


the client program and the various services that are also running in user space.
21

Modules
 loadable kernel modules (LKMs).
 Here, the kernel has a set of core components and can link in
additional services via modules, either at boot time or during run time.

Hybrid Systems
 combine different structures, resulting in hybrid systems that address
performance, security, and usability issues.
 For example, Linux is monolithic, because having the operating system in
a single address space provides very efficient performance. However, it
also modular, so that new functionality can be dynamically added to the
kernel.

macOS and iOS


 Apple’s macOS operating system is designed to run primarily on
desktop and laptop computer systems, whereas iOS is a mobile
operating system designed for the iPhone smartphone and iPad tablet
computer.
 Highlights of the various layers include the following:
• User experience layer.
• This layer defines the software interface that allows users to
interact with the computing devices.
• macOS uses the Aqua user interface
• Application frameworks layer.
• This layer includes the Cocoa and Cocoa Touch frameworks,
which provide an API for the Objective-C and Swift programming
languages.
• Core frameworks. This layer defines frameworks that support graphics
and media including, Quicktime and OpenGL.
22

 Kernel environment.
 This environment, also known as Darwin, includes the Mach
microkernel and the BSD UNIX kernel.

Android
 The Android operating system was designed by the Open Handset
Alliance (led primarily by Google) and was developed for Android
smartphones and tablet computers.
 The structure of Android appears in Figure 2.18.
 Android is similar to iOS in that it is a layered stack of software that
provides a rich set of frameworks supporting graphics, audio, and
hardware features.
 These features, in turn, provide a platform for developing mobile
applications that run on a multitude of Android-enabled devices.
23

The operating system should support


 Multiprogramming
o Multiprogramming increases CPU utilization by organizing jobs (code
and data) so that the CPU always has one to execute.

Time sharing (or multitasking)


 Time sharing (or multitasking) is a logical extension of multiprogramming.
 In time-sharing systems, the CPU executes multiple jobs by switching among them,
but the switches occur so frequently that the users can interact with each program
while it is running.
Job and CPU scheduling
 If several jobs are ready to be brought into memory, and if there is not enough
room for all of them, then the system must choose among them.
 Making this decision involves job scheduling.
24

 If several jobs are ready to run at the same time, the system must choose which job
will run first. Making this decision is CPU scheduling.
Swapping
 In a time-sharing system, the operating system must ensure reasonable response
time.
 This goal is sometimes accomplished through swapping, whereby processes are
swapped in and out of main memory to the disk.
Virtual, physical & logical memory
 virtual memory, a technique that allows the execution of a process that is not
completely in memory.
25

OPERATING-SYSTEM SERVICES
 An operating system provides an environment for the execution of programs.
 It makes certain services available to programs and to the users of those pro-
grams.

 User interface.
 Almost all operating systems have a user interface (UI). This
interface can take several forms.
 Graphical user interface (GUI).
• the interface is a window system with
• a mouse that serves as a pointing device to direct I/O,
choose from menus, and make selections and
• a keyboard to enter text.
 touch-screen interface
• Mobile systems such as phones and tablets provide a touch-
screen interface, enabling users to slide their fingers across
the screen or press buttons on the screen to select choices.
 command-line interface (CLI),
• uses text commands and a method for entering them
 Program execution.
 The system must be able to load a program into memory and to run
that program.
 I/O operations.
26

 A running program may require I/O, which may involve a file


or an I/O device.
 File-system manipulation.
 programs need to read and write files and directories.
 They also need to create and delete them by name, search for a
given file, and list file information.
 Finally, some operating systems include permissions management to
allow or deny access to files or directories based on file ownership.
 Communications.
 Communications may be implemented via
• shared memory, in which two or more processes read and write
to a shared section of memory, or
• message passing, in which packets of information in predefined
formats are moved between processes by the operating system.
 Error detection.
• The operating system needs to be detecting and correcting
errors constantly.
• Errors may occur
• in the CPU and memory hardware,
• in I/O devices
• and in the user program
 Resource allocation.
 When there are multiple processes running at the same time, resources
must be allocated to each of them.
 The operating system manages many different types of resources.
 Some (such as CPU cycles, main memory, and file storage) may have
special allocation code,
 whereas others (such as I/O devices) may have much more general
request and release code.
 Logging.
 We want to keep track of which programs use how much and what
kinds of computer resources.
 Protection and security.
 The owners of information stored in a multiuser or networked
computer system may want to control use of that information.
 When several separate processes execute concurrently, it should not
be possible for one process to interfere with the others or with the
operating system itself.
27

User and Operating-System Interface


there are several ways for users to interface with the operating
system.
 One provides a command-line interface, or command interpreter,
that allows users to directly enter commands to be performed by
the operating system.
 The other two allow users to interface with the operating system
via a graphical user interface, or GUI.
 Command Interpreters
 Most operating systems, including Linux, UNIX, and Windows,
treat the com- mand interpreter as a special program that is running
when a process is initiated or when a user first logs on.
 On systems with multiple command interpreters to choose from,
the interpreters are known as shells.
 Figure 2.2 shows the Bourne-Again (or bash) shell command
interpreter being used on macOS.
 The main function of the command interpreter is to get and
execute the next user-specified command.
 Many of the commands given at this level manipulate files: create,
delete, list, print, copy, execute, and so on.
 These commands can be implemented in two general ways.
o In one approach, the command interpreter itself contains
the code to execute the command.
o An alternative approach— used by UNIX, among other
operating systems implements most commands through
system programs.
 Thus, the UNIX command to delete a file

rm file.txt

would search for a file called rm, load the file into memory, and execute it
with the parameter file.txt.
28

Figure 2.2 The bash shell command interpreter in macOS.

 Graphical User Interface


 users employ a mouse-based window-and-menu system
characterized by a desktop 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.
 The first GUI appeared on the Xerox Alto computer in 1973.
 Traditionally, UNIX systems have been dominated by command-line
inter- faces.
 Touch-Screen Interface
 Because a either a command-line interface or a mouse-and-
keyboard system is impractical for most mobile systems,
smartphones and handheld tablet com- puters typically use a
touch-screen interface.
 Here, users interact by making gestures on the touch screen— for
example, pressing and swiping fingers across the screen.
 Although earlier smartphones included a physical keyboard, most
smartphones and tablets now simulate a keyboard on the touch
screen. Figure 2.3 illustrates the touch screen of the Apple iPhone.
29

Figure 2.3 The iPhone touch screen.


 Choice of Interface
 The choice of whether to use a command-line or GUI interface is mostly
one of personal preference.
 System administrators who manage computers and power users who have
deep knowledge of a system frequently use the command-line interface.
 For them, it is more efficient, giving them faster access to the activities
they need to perform.
 In contrast, most Windows users are happy to use the Windows GUI envi-
ronment and almost never use the shell interface.

Figure 2.4 The macOS GUI.


System calls
 Introduction
 Types of system calls

1. Introduction:
 System calls provide an interface to the services made available by an
operating system.
 These calls are generally available as routines written in C and C++, may have
to be written using assembly-language instructions.
 System call interface:
o For most programming languages, the run-time support system provides
a system call interface that serves as the link to system calls made
available by the operating system.

 The relationship between an API, the system-call interface, and the operating
system is shown in Figure 2.6, which illustrates how the operating system handles a
user application invoking the open() system call.

2. Types of system calls:


o System calls can be grouped roughly into six major categories:
30
1. Process control,
2. file manipulation,
3. device manipulation,
4. information maintenance,
5. communications,
6. Protection

1. Process control:
i. end, abort
ii. load, execute
iii. create process, terminate process
iv. get process attributes, set process attributes
v. wait for time
vi. wait event, signal event

 A running program needs to be able to stop execution either normally using end( )
or abnormally using abort( ).
 A process or job executing one program may want to load( ) and execute( ) another
program.
 The system call specifically for creating a new job or process to be
multiprogrammed is create_process( ) or submit_job( ).
 the ability to determine and reset the attributes of a job or process, including the
job’s priority, its maximum allowable execution time, and so on (get process
attributes( ) and set process attributes( )).
 We may terminate a job or process that we created (terminate process( )) if we find
that it is incorrect or is no longer needed.
 We may want to wait for a certain amount of time to pass (wait time( )).
 More probably, we will want to wait for a specific event to occur (wait event( )).
 The jobs or processes should then signal when that event has occurred (signal
event( )).

2. File manipulation:
i. create file, delete file
ii. open, close
iii. read, write, reposition
iv. get file attributes, set file attributes

 We first need to be able to create( ) and delete( ) files.


31
 Either system call requires the name of the file and perhaps some of the file’s
attributes.
 Once the file is created, we need to open( ) it and to use it.
 We may also read( ), write( ), or reposition( ) (rewind or skip to the end of the file,
for example).
 Finally, we need to close( ) the file, indicating that we are no longer using it.
 File attributes include the,
o file name
o file type
o protection codes
o accounting information, and so on.
 At least two system calls, get file attributes( ) and set file attributes( ), are required
for this function.
 Some operating systems provide many more calls, such as calls for file move( ) and
copy().

3. Device manipulation:
i. request device, release device
ii. read, write, reposition
iii. get device attributes, set device attributes
iv. logically attach or detach devices

 A process may need several resources to execute—main memory, disk drives,


access to files, and so on.
 If the resources are available, they can be granted, and control can be returned to
the user process.
 Otherwise, the process will have to wait until sufficient resources are available.
 The various resources controlled by the operating system can be thought of as
devices. Some of these devices are physical devices (for example, disk drives),
while others can be thought of as abstract or virtual devices (for example, files).
 A system with multiple users may require us to first request( ) a device, to ensure
exclusive use of it.
 After we are finished with the device, we release( ) it.
 These functions are similar to the open( ) and close( ) system calls for files.
 Other operating systems allow unmanaged access to devices.

2. Information maintenance:
i. get time or date, set time or date
32
ii. get system data, set system data
iii. get process, file, or device attributes
iv. set process, file, or device attributes
 Many system calls exist simply for the purpose of transferring information between
the user program and the operating system.
 For example, most systems have a system call to return the current time( ) and date(
).
 Other system calls may return information about the system, such as,
o the number of current users,
o the version number of the operating system,
o the amount of free memory or disk space, and so on.
 Another set of system calls is helpful in debugging a program.
 Many systems provide system calls to dump( ) memory. This provision is useful for
debugging.
 In addition, the operating system keeps information about all its processes, and
system calls are used to access this information.
 Generally, calls are also used to reset the process information
(get_process_attributes( ) and set_process_attributes( )).

3. Communications:
i. create, delete communication connection
ii. send, receive messages
iii. transfer status information
iv. attach or detach remote devices

 There are two common models of interprocess communication:


o the message passing model
o the shared-memory model.
 message-passing model-
o In the message-passing model, the communicating processes exchange
messages with one another to transfer information.
o Messages can be exchanged between the processes either directly or
indirectly through a common mailbox.
o Each computer in a network has a host name by which it is commonly
known. A host also has a network identifier, such as an IP address.
o Similarly, each process has a process name, and this name is translated
into an identifier by which the operating system can refer to the process.
o The get_hostid( ) and get_processid( ) system calls do this translation.
33
o The identifiers are then passed to the general purpose open( ) and close(
) calls provided by the file system or to specific open_connection( ) and
close_connection( ) system calls, depending on the system’s model of
communication.
o The recipient process usually must give its permission for
communication to take place with an accept_connection( ) call.
o Most processes that will be receiving connections are special-purpose
daemons, which are system programs provided for that purpose.
o They execute a wait_for_connection( ) call and are awakened when a
connection is made.
o The source of the communication, known as the client, and the
receiving daemon, known as a server, then exchange messages by using
read_message( ) and write_message( ) system calls.
o The close_connection( ) call terminates the communication.
 shared-memory model-
o In the shared-memory model, processes use shared_memory_create( ) and
shared_memory_attach( ) system calls to create and gain access to regions
of memory owned by other processes.
o Shared memory requires that two or more processes agree to remove this
restriction.
o They can then exchange information by reading and writing data in the
shared areas.
 Merit of Message passing:
o useful for exchanging smaller amounts of data, because no conflicts need
be avoided.
o easier to implement than is shared memory for intercomputer
communication.
 Merit of Shared memory:
o allows maximum speed and convenience of communication, since it can be
done at memory transfer speeds when it takes place within a computer.
 Demerit of message-passing and shared memory:
o areas of protection
o synchronization between the processes sharing memory.

4. Protection:
 Protection provides a mechanism for controlling access to the resources provided
by a computer system.

34
 Typically, 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.

35
36
System Programs
 Definition
 Categories

1. Definition:
 System programs provide a convenient environment for program development and
execution.
 Also known as system utilities.

2. Categories:
 File Management
 Status Information
 File Modification
 Programming-language support
 Program loading and execution
 Communications
 Background services

 File management:
o File is a collection of related information.
o These programs,
a. create
b. delete
c. copy
d. rename
e. print
f. dump and list files and directories.

 Status information:
o Information related to,
a. Date,
b. time,
c. amount of available memory or disk space
d. number of users or similar status information.
o Complex information like,
a. Performance
b. Logging
c. Debugging information
 File modification:
 Text editors may be available to create and modify the content of files
stored on disk or other storage devices.
 Programming-language support:

37
 Compilers, assemblers, debuggers and interpreters for common
programming languages like C, C++, Java are provided with OS or
available as a separate download.

 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 create virtual connections among processes, users, and
different computer systems. (email, FTP, Remote log in).
 It allow users to,
 Send messages to other’s screen
 Browse web pages
 Send e-mail
 Remote log-in
 Transfer files

 Background services:
 All general-purpose systems have methods for launching certain system-
program processes at boot time.
 Constantly running system-program processes are known as services,
subsystems, or daemons.

38
OPERATING-SYSTEM DESIGN AND IMPLEMENTATION
 Design Goals
 The first problem in designing a system is to define goals and
specifications.
 The requirements can, however, be divided into two basic groups:
 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.
 Mechanisms and Policies
 One important principle is the separation of policy from mechanism.
 Mechanisms determine how to do something;
 policies determine what will be done.
 Policy decisions are important for all resource allocation. Whenever
it is necessary to decide whether or not to allocate a resource, a
policy decision must be made.
 Whenever the question is how rather than what, it is a mechanism
that must be determined.
 Implementation
 Once an operating system is designed, it must be implemented.
 Because operating systems are collections of many programs,
written by many people over a long period of time, it is difficult to
make general statements about how they are implemented.
 Early operating systems were written in assembly language.
 Now, most are written in higher-level languages such as C or C++,
with small amount of the system written in assembly language
 The advantages of using a higher-level language,
 the code can be written faster, is more compact, and is easier
to understand and debug.
 improvements in compiler technology will improve the
generated code for the entire operating system by simple
recompilation.
 an operating system is far easier to port to other hardware
if it is written in a higher-level language.

39
 The only possible disadvantages of implementing an operating
system in a higher-level language are reduced speed and increased
storage requirements.

40

You might also like