0% found this document useful (0 votes)
0 views9 pages

Os Unit2

The document provides an overview of operating system structures, detailing the essential services offered by operating systems such as program execution, I/O operations, file system manipulation, communication, error handling, resource management, accounting, and protection. It also discusses user interfaces, including command-line and graphical user interfaces, as well as system calls that allow programs to request services from the operating system. Furthermore, it categorizes system calls into five major types: process control, file management, device management, information maintenance, and communications.

Uploaded by

swethasankar581
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views9 pages

Os Unit2

The document provides an overview of operating system structures, detailing the essential services offered by operating systems such as program execution, I/O operations, file system manipulation, communication, error handling, resource management, accounting, and protection. It also discusses user interfaces, including command-line and graphical user interfaces, as well as system calls that allow programs to request services from the operating system. Furthermore, it categorizes system calls into five major types: process control, file management, device management, information maintenance, and communications.

Uploaded by

swethasankar581
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

UNIT – II

Operating-System Structures

OVERVIEW
Operating-System Services

User Operating-System Interface

System Calls

Types of System Calls

Operating-System Design and Implementation


Virtual Machines

OS DEBUGGING
Operating-System Services
An operating system provides an environment for the execution of programs. It provides certain
services to programs and to the users of those programs. The specific services provided, of
course, differ from one operating system to another, but we can identify common classes. These
operating-system services are provided for the convenience of the programmer, to make the
programming task easier.

Following are a few common services provided by an operating system −

 Program execution
 I/O operations
 File System manipulation
 Communication
 Error Detection
 Resource Allocation
 Accounting
 Protection

Program execution
Operating systems handle many kinds of activities from user programs to system
programs like printer spooler, name servers, file server, etc. Each of these activities is
encapsulated as a process.
A process includes the complete execution context (code to execute, data to
manipulate, registers, OS resources in use). Following are the major activities of an
operating system with respect to program management −

 Loads a program into memory.


 Executes the program.
 Handles program's execution.
 Provides a mechanism for process synchronization.
 Provides a mechanism for process communication.
 Provides a mechanism for deadlock handling.

I/O Operation
An I/O subsystem comprises of I/O devices and their corresponding driver software.
Drivers hide the peculiarities of specific hardware devices from the users.
An Operating System manages the communication between user and device drivers.
 I/O operation means read or write operation with any file or any specific I/O
device.
 Operating system provides the access to the required I/O device when required.

File system manipulation


A file represents a collection of related information. Computers can store files on the
disk (secondary storage), for long-term storage purpose. Examples of storage media
include magnetic tape, magnetic disk and optical disk drives like CD, DVD. Each of
these media has its own properties like speed, capacity, data transfer rate and data
access methods.
A file system is normally organized into directories for easy navigation and usage.
These directories may contain files and other directions. Following are the major
activities of an operating system with respect to file management −

 Program needs to read a file or write a file.


 The operating system gives the permission to the program for operation on file.
 Permission varies from read-only, read-write, denied and so on.
 Operating System provides an interface to the user to create/delete files.
 Operating System provides an interface to the user to create/delete directories.
 Operating System provides an interface to create the backup of file system.

Communication
In case of distributed systems which are a collection of processors that do not share
memory, peripheral devices, or a clock, the operating system manages
communications between all the processes. Multiple processes communicate with one
another through communication lines in the network.
The OS handles routing and connection strategies, and the problems of contention and
security. Following are the major activities of an operating system with respect to
communication −

 Two processes often require data to be transferred between them


 Both the processes can be on one computer or on different computers, but are
connected through a computer network.
 Communication may be implemented by two methods, either by Shared Memory
or by Message Passing.

Error handling
Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or
in the memory hardware. Following are the major activities of an operating system with
respect to error handling −

 The OS constantly checks for possible errors.


 The OS takes an appropriate action to ensure correct and consistent computing.

Resource Management
In case of multi-user or multi-tasking environment, resources such as main memory,
CPU cycles and files storage are to be allocated to each user or job. Following are the
major activities of an operating system with respect to resource management −

 The OS manages all kinds of resources using schedulers.


 CPU scheduling algorithms are used for better utilization of CPU.

Accounting.
We want to keep track of which users use how much and what kinds of computer resources. This record
keeping may be used for accounting (so that users can be billed) or simply for accumulating usage
statistics. Usage statistics may be a valuable tool for researchers who wish to reconfigiire the system to
improve computing services.

Protection
Considering a computer system having multiple users and concurrent execution of
multiple processes, the various processes must be protected from each other's
activities.
Protection refers to a mechanism or a way to control the access of programs,
processes, or users to the resources defined by a computer system. Following are the
major activities of an operating system with respect to protection −

 The OS ensures that all access to system resources is controlled.


 The OS ensures that external I/O devices are protected from invalid access
attempts.
 The OS provides authentication features for each user by means of passwords.

User Operating-System Interface


There are two fundamental approaches for users to interface with the operating system. One technique is
to provide a command-line interface or command interpreter that allows users to directly enter
commands that are to be performed by the operating system. The second approach allows the user to
interface with the operating system via a graphical user interface or GUI.
Command Interpreter

Some operating systems include the command interpreter in the kernel. Others, such as Windows XP and
UNIX, treat the command interpreter as a special program that is running when a job is initiated or when
a user first logs on (on interactive systems). On systems with multiple command interpreters to choose
from, the interpreters are known as shells. For example, on UNIX and Linux systems, there are several
different shells a user may choose from including the Bourne shell, C shell, Bourne-Again shell, the Korn
shell, etc. Most shells provide similar functionality with only minor differences; most users choose a shell
based upon personal preference.

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. The MS-DOS and UNIX shells operate in this way. There are two
general ways in which these commands can be implemented. In one approach, the command
interpreter itself contains the code to execute the command. For example, a command to delete a
file may cause the command interpreter to jump to a section of its code that sets up the
parameters and makes the appropriate system call.

An alternative approach—used by UNIX, among other operating systems —implements most


commands through system programs.

Graphical User Interfaces


A second strategy for interfacing with the operating system is through a userfriendly graphical
user interface or GUI. Rather than having users directly enter commands via a command-line
interface, a GUI allows provides a mouse-based window-and-menu system as an interface. A
GUI provides a desktop metaphor where the mouse is moved 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.

Graphical user interfaces first appeared due in part to research taking place in the early 1970s at
Xerox PARC research facility. The first GUI appeared on the Xerox Alto computer in 1973.
However, graphical interfaces became more widespread with the advent of Apple Macintosh
computers in the 1980s Traditionally, UNIX systems have been dominated by command-line
interfaces, although there are various GUI interfaces available, including the Common Desktop
Environment (CDE) and X-Windows systems that are common on commercial versions of UNIX
such as Solaris and IBM's AIX system. However, there has been significant development in GUI designs
from various opensource projects such as K Desktop Environment (or KDE) and the GNOME desktop by
the GNU project. Both the KDE and GNOME desktops rim on Linux and various UNIX systems and are
available under open-source licenses, which means their source code is in the public domain.

System Calls
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++, although certain low-level tasks (for example, tasks
where hardware must be accessed directly), may need to be written using assembly-language instructions.

In computing, a system call is the programmatic way in which a computer program requests a
service from the kernel of the operating system it is executed on. A system call is a way for
programs to interact with the operating system. A computer program makes a system call
when it makes a request to the operating system’s kernel. System call provides the services of
the operating system to the user programs via Application Program Interface(API). It provides
an interface between a process and operating system to allow user-level processes to request
services of the operating system. System calls are the only entry points into the kernel system.
All programs needing resources must use system calls.
Once the two file names are obtained, the program must open the input file and create the output file.
Each of these operations requires another system call. There are also possible error conditions for each
operation. When the program tries to open the input file, it may find that there is no file of that name or
that the file is protected against access. In these cases, the program should 8 print a message on the console
(another sequence of system calls) and then terminate abnormally (another system call). If the input file
exists, then we must create a new output file. We may find that there is already an output file with the
same name. This situation may cause the program to abort (a system call), or we may delete the existing
file (another system call) and create a new one (another system call). Another option, in an interactive
system, is to ask the user (via a sequence of system calls to output the prompting message and to read the
response from the terminal) whether to replace the existing file or to abort the program.

Now that both files are set up, we enter a loop that reads from the input file (a system call) and writes to
the output file (another system call). Each read and write must return status information regarding various
possible error conditions. On input, the program may find that the end of the file has been reached or that
there was a hardware failure in the read (such as a parity error). The write operation may encounter
various errors, depending on the output Device

Most programmers never see this level of detail, however. Typically, application developers design
programs according to an application programming interface (API). 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 of the most common APIs
available to application programmers are the Win32 API for Windows systems, the POSIX API for
POSIX-based systems (which includes virtually all versions of UNIX, Linux, and Mac OS X), and the
Java API for
designing programs that run on the Java virtual machine.
EXAMPLE OF STANDARD API
As an example of a standard API, consider the ReadFileQ function in the
Win32 API—a function for reading from a file. The API for this function
appears

A description of the parameters passed to ReadFileO is as follows:


• '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—i ndicates i f overl apped I / O i s being used.
System calls occur in different ways, depending on the computer in use. Often, more information is
required than simply the identity of the desired system call. The exact type and amount of information
vary according to the particular operating system and call. For example, to get input, we may need
to specify the file or device to use as the source, as well as the address and length of the memory buffer
into which the input should be read. Of course, the device or file and length may be implicit in the call.

Types of System Calls


System calls can be grouped roughly into five major categories: process control, file manipulation,
device manipulation, information maintenance, and communications the types of system calls that
may be provided by an operating system. Most of these system calls support, or are supported by,
concepts and functions that are discussed in later chapters. the types of system calls normally provided by
an operating system.

Process control
o end, abort
o load, execute
o create process, terminate process
o get process attributes, set process attributes
o wait for time
o wait event, signal event
o allocate and free memory

• File management
° create file, delete file
o open, close
° read, write, reposition
o get file attributes, set file attributes

• Device management
o request device, release device
° read, write, reposition
o get device attributes, set device attributes
° logically attach or detach devices

• Information maintenance

o get time or date, set time or date


o get system data, set system data
o get process, file, or device attributes
o set process, file, or device attributes

• Communications
0 create, delete communication connection
° send, receive messages
o transfer status information
o attach or detach remote devices

Process Control
These system calls deal with processes such as process creation, process termination
etc.
File Management
These system calls are responsible for file manipulation such as creating a file, reading
a file, writing into a file etc.
Device Management
These system calls are responsible for device manipulation such as reading from device
buffers, writing into device buffers etc.
Information Maintenance
These system calls handle information and its transfer between the operating system
and the user program.
Communication
These system calls are useful for interprocess communication. They also deal with
creating and deleting a communication connection.

You might also like