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

Unit-1 Operating System

Uploaded by

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

Unit-1 Operating System

Uploaded by

Laxman Rao
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

UNIT – 1

Syllabus:
Operating Systems Overview: Operating system functions, Operating system structure,
Operating systems operations, Computing environments, Open-Source Operating Systems.
System Structures: Operating System Services, User and Operating-System Interface, systems
calls, Types of System Calls, system programs, operating system structure, operating system
debugging, System Boot.

INTRODUCTION:

Operating System:
An Operating System is a program that manages the computer hardware. It also provides a basis
for application programs and act as an intermediary between the computer user and the computer
hardware. An amazing aspect of operating systems is how they vary in accomplishing these
tasks. Mainframe operating systems are designed primarily to optimize utilization of hardware.
Personal computer (PC) operating systems support complex games, business applications, and
everything in between. Operating systems for mobile computers provide an environment in
which a user can easily interface with the computer to execute programs. Thus, some operating
systems are designed to be convenient, others to be efficient, and others to be some combination
of thetwo.

Fig1.1: Abstract view of the components of a computer system

A computer system can be divided roughly into four components: the hardware, the
operating system, the application programs, and the users as shown in the figure 1.1. 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, spread sheets, 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
varioususers.

Functions of Operating System:


An Operating System acts as a communication bridge (interface) between the user and
computer hardware. The purpose of an operating system is to provide a platform on which a
user can execute programs in a convenient and efficient manner.

An operating system is a piece of software that manages the allocation of computer hardware.
The coordination of the hardware must be appropriate to ensure the correct working of the
computer system and to prevent user programs from interfering with the proper working of the
system.

Example: Just like a boss gives order to his employee, in the similar way we request or pass
our orders to the Operating System. The main goal of the Operating System is to thus make the
computer environment more convenient to use and the secondary goal is to use the resources
in the most efficient manner.

Important functions of an operating System:

Security

The operating system uses password protection to protect user data and similar other techniques.
It also prevents unauthorized access to programs and user data.

Control over system performance

Monitors overall system health to help improve performance. Records the response time between
service requests and system response to have a complete view of the system health. This can help
improve performance by providing important information needed to troubleshoot problems.

Job accounting
Operating system Keeps track of time and resources used by various tasks and users, this
information can be used to track resource usage for a particular user or group of user.

Error detecting aids

Operating system constantly monitors the system to detect errors and avoid the malfunctioning
of computer system.

Coordination between other software and users

Operating systems also coordinate and assign interpreters, compilers, assemblers and other
software to the various users of the computer systems.

Memory Management

The operating system manages the Primary Memory or Main Memory. Main memory is made up
of a large array of bytes or words where each byte or word is assigned a certain address. Main
memory is a fast storage and it can be accessed directly by the CPU. For a program to be
executed, it should be first loaded in the main memory. An Operating System performs the
following activities for memory management:

It keeps tracks of primary memory, i.e., which bytes of memory are used by which user program.
The memory addresses that have already been allocated and the memory addresses of the
memory that has not yet been used. In multi programming, the OS decides the order in which
process are granted access to memory, and for how long. It allocates the memory to a process
when the process requests it and deallocates the memory when the process has terminated or is
performing an I/O operation.

Processor Management

In a multi programming environment, the OS decides the order in which processes have access to
the processor, and how much processing time each process has. This function of OS is called
process scheduling. An Operating System performs the following activities for processor
management.

Keeps tracks of the status of processes. The program which performs this task is known as traffic
controller. Allocates the CPU that is processor to a process. De-allocates processor when a
process is no more required.

Device Management

An OS manages device communication via their respective drivers. It performs the following
activities for device management. Keeps tracks of all devices connected to system. Designates a
program responsible for every device known as the Input/Output controller. Decides which
process gets access to a certain device and for how long. Allocates devices in an effective and
efficient way. Deallocates devices when they are no longer required.

File Management

A file system is organized into directories for efficient or easy navigation and usage. These
directories may contain other directories and other files. An Operating System carries out the
following file management activities. It keeps track of where information is stored, user access
settings and status of every file and more… These facilities are collectively known as the file
system.

OPERATING SYSTEM STRUCTURE:


A system as large and complex as a modern operating system must be engineered carefully if
it is to function properly A common approach is to partition the task into small components, or
modules, rather than have one monolithic system. Each of these modules should be a well-
defined portion of the system, with carefully defined inputs, outputs, and functions.
Simple Structure:
Many operating systems do not have well-defined structures. Frequently, such systems started
as small, simple, and limited systemsand then grew beyond their original scope. MS-DOS is an
example of such a system. It was originally designed and implemented by a few people who
had no idea that it would become so popular. It was written to provide the most functionality in
the least space, so it was not carefully divided into modules. Figure 1.2 shows itsstructure.

Fig 1.2: MS-DOS layer architecture

In MS-DOS, the interfaces and levels of functionality are not well separated. For instance,
application programs are able to access the basic I/O routines to write directly to the display
and disk drives. It leads to malicious programs, causing entire system crash when user
programs fail. It is also limited by the hardware of its era. Because the Intel 8088 for which it
was written provides no dual mode and no hardware protection, the designers of MS-DOS had
no choice but to leave the base hardware accessible. Another example of limited structuring is
the original UNIX operating system. Like MS-DOS, UNIX initially was limited by hardware
functionality. It consists of two separable parts: the kernel and the system programs. The
kernel is further separated into a series of interfaces and device drivers. The traditional unix
operating system is shown in the figure1.3:

Fig 1.3: Traditional UNIX system structure

Everything below the system-call interface and above the physical hardware is the kernel. The
kernel provides the file system, CPU scheduling, memory management, and other operating-
system functions through systemcalls.
LayeredApproach:
In layered approach, the operating system is broken into a number of layers (levels). The
bottom layer (layer 0) is the hardware; the highest (layer N) is the user interface. This layering
structure is depicted in Figure 1.4.
Fig 1.4: A layered operating system

The main advantage of the layered approach is simplicity of construction and debugging. The
layers are selected so that each uses functions (operations) and services of only lower-level
layers. This approach simplifies debugging and system verification. The first layer can be
debugged without any concern for the rest of the system, because, by definition, it uses only
the basic hardware (which is assumed correct) to implement itsfunctions.
Once the first layer is debugged, its correct functioning can be assumed while the second layer
is debugged, and so on. If an error is found during the debugging of a particular layer, the error
must be on that layer, because the layers below it are already debugged. Thus, the design and
implementation of the system aresimplified
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. Hence, each layer hides the existence of certain data structures, operations,
and hardware from higher-level layers.

Limitations:

1. The major difficulty with the layered approach involves appropriately defining the
various layers. Because a layer can use only lower-level layers, careful planning
isnecessary.
2. Another problem with layered implementations is that they tend to be less efficient than
other types. At each layer, the parameters may be modified; data may need to be passes
and so on. This increases the overhead at the system call. The net result will be the
system call that takes longer time thanusual.

Micro-kernels:
Mach operating system modularizes the kernel using the microkernel approach. This method
structures the operating system by removing all non-essential components from the kernel and
implementing them as system or user level programs. This results in smaller kernel. Micro-
kernels provide minimal process and memory management, in addition to the communication
facility. Fig 1.5 represents the architecture of typicalmicrokernel.

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. Communication is provided
through message passing.

Fig 1.5: Architecture of typical microkernel


Benefits of Microkernel:
One benefit of the microkernel approach is that it makes extending the operating system easier.
All new services are added to user space and consequently do not require modification of the
kernel. When the kernel does have to be modified, the changes tend to be fewer, because the
microkernel is a smaller kernel. The resulting operating system is easier to port from one
hardware design to another. The microkernel also provides more security and reliability, since
most services are running as use rather than kernelprocesses

Modules:
The best current methodology for operating system design involves using loadable kernel
modules. Here, the kernel has a set of core components and links in additional services via
modules, either at boot time or during run time. This type of design is common in modern
implementations of UNIX, such as Solaris, Linux, and Mac OS X, as well asWindows.
The idea of the design is for the kernel to provide core services while other services are
implemented dynamically, as the kernel is running. The architecture of Solaris system is
provided below:

Fig 1.6: Solaris loadable


modules

The Solaris operating system structure, shown is organized around a core kernel with seven
types of loadable kernel modules:
1. Schedulingclasses 5. StreamsModules
2. FileSystems 6.Miscellaneous
3. Loadablesystemcalls 7. Device and busdrivers.
4. ExecutableFormats
Linux also uses loadable kernel modules, primarily for supporting device drivers and file
systems.
Hybrid Systems:
A very few operating systems adopt a single, strictly defined structures. Instead they combine
different structures, resulting in hybrid systems that address performances, security and
usability issues.

MAC OS X:
The Apple Mac OS X operating system uses a hybrid structures. The structure is shown in the
figure 1.7, it’s a layeredsystem.
Fig 1.7: The Mac OS X structure

The top layers include the Aqua user interface and a set of application environments and
services. Notably, the Cocoa environment specifies an API for the Objective-C programming
language, which is used for writing Mac OS X applications. Below these layers is the kernel
environment, which consists primarily of the Mach microkernel and the BSD UNIX kernel.
Mach provides memory management; support for remote procedure calls (RPCs) and inter-
process communication (IPC) facilities, including message passing; and thread scheduling.
The BSD component provides a BSD command-line interface, support for networking and file
systems, and an implementation of POSIX APIs, including Pthreads. In addition to Mach and
BSD, the kernel environment provides an I/O kit for development of device drivers and
dynamically loadablemodules.

Android

The Android operating system was designed by the Open Handset Alliance (led primarily by
Google) and was developed for Android smart-phones and tablet computers. Whereas iOS is
designed to run on Apple mobile devices and is close-sourced, Android runs on a variety of
mobile platforms and is open- sourced,partlyexplainingitsrapidriseinpopularity.Thestructure
ofAndroidappearsinFigure1.8
Fig 1.8: Architecture of Google’s Android

It is a layered stack of software that provides a rich set of frameworks for developing mobile
applications. At the bottom of this software stack is the Linux kernel, although it has been
modified by Google and is currently outside the normal distribution of Linuxreleases.
The set of libraries available for Android applications includes frameworks for developing
web browsers (webkit), database support (SQLite), and multimedia. The libc library is similar
to the standard C library
butismuchsmallerandhasbeendesignedfortheslowerCPUsthatcharacterizemobiledevices.
Operating systems operations:

Modern operating systems are interrupt driven. Events are signaled by the occurrence of an
interrupt ora trap. A trap (or an exception) is a software-generated interrupt caused either by
an error (for example, division by zero or invalid memory access) or by a specific request from
a user program that an operating-system service be performed. For each type of interrupt,
separate segments of code in the operating system determine what action should be taken. An
interrupt service routine is provided to deal with theinterrupt.

Dual Mode and Multimode Operation:


In order to ensure the proper execution of the operating system, distinguishing between the
execution of operating-system code and user defined code should be done. The approach taken
by most computer systems is to provide hardware support that allows us to differentiate
among various modes of execution. In general there are two different types ofmodes:
 UserMode
 Kernel Mode (also called supervisor mode, system mode or privilegedmode)
A bit, called mode bit, is added the hardware of the computer to indicate the current mode:
kernel (0) or user (1). When the computer system is executing on behalf of the user
application, the system is in user

mode. However when a user application requests a service from the operating system, the
system must transition from user to kernel mode to fulfill the request. This is shown in the

figure 1.9:
Fig 1.9: Transition from user mode 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).
Thus, 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
userprogram.
Timer:
The operating system must maintain a control over the CPU. It cannot allow the user program
to stuck in an infinite loop or fail to call system services and never return control to the
operating system. To accomplish this goal we use timer. A timer can be set to interrupt the
computer after a specified period. The period may be fixed or variable. A “variable timer” is
generally implemented by a fixed rate clock and a counter. The operating system sets the
counter. Every time the clock ticks, the counter is decremented. When the counter reaches 0,
an interrupt occurs. Before turning over the control to the user, the operating system ensures
that the timer is set tointerrupt.
Timers can also be used to prevent the user program from running too long. A simple
technique is to initialize the counter with the amount of time that a program is allowed to run.

Computing environments

A computer system uses many devices, arranged in different ways to solve many problems.
This constitutes a computing environment where many computers are used to process and
exchange information to handle multiple issues.
The different types of Computing Environments are

Fig 1.10: different types of Computing Environments

Personal Computing Environment

In the personal computing environment, there is a single computer system. All the system
processes are available on the computer and executed there. The different devices that constitute
a personal computing environment are laptops, mobiles, printers, computer systems, scanners
etc.
Time Sharing Computing Environment

The time sharing computing environment allows multiple users to share the system
simultaneously. Each user is provided a time slice and the processor switches rapidly among the
users according to it. Because of this, each user believes that they are the only ones using the
system.

Client Server Computing Environment

In client server computing, the client requests a resource and the server provides that resource. A
server may serve multiple clients at the same time while a client is in contact with only one
server. Both the client and server usually communicate via a computer network but sometimes
they may reside in the same system.

Distributed Computing Environment

A distributed computing environment contains multiple nodes that are physically separate but
linked together using the network. All the nodes in this system communicate with each other and
handle processes in tandem. Each of these nodes contains a small part of the distributed
operating system software.

Cloud Computing Environment

The computing is moved away from individual computer systems to a cloud of computers in
cloud computing environment. The cloud users only see the service being provided and not the
internal details of how the service is provided. This is done by pooling all the computer resources
and then managing them using a software.

Cluster Computing Environment

The clustered computing environment is similar to parallel computing environment as they both
have multiple CPUs. However a major difference is that clustered systems are created by two or
more individual computer systems merged together which then work parallel to each other.

Open-Source Operating Systems

On a closed-source OS like Windows, that code can only be altered by Microsoft, and only
viewed by few selected customers like big companies.

In contrast, the code underlying open-source operating systems is not only freely available for
anyone to view but also to modify, use and share, under the terms of open-source licences such
as MIT, GNU Public Licence, and Apache 2.0.

 OpenBSD

 Linux
 FreeBSD

 NetBSD

 Dragonfly BSD

 Qubes OS

 Haiku

 Redox

 ReactOS

 AROS

 FreeDOS

 BASIC-DOS

 skiftOS

 Tock

 Subgraph OS

OpenBSD

 The OpenBSD project produces a FREE, multi-platform 4.4BSD-based UNIX-like


operating system.

 It efforts emphasize portability, standardization, correctness, proactive security and


integrated cryptography.

 As an example of the effect OpenBSD has, the popular OpenSSH software comes from
OpenBSD.

Linux

 Linux is a family of open-source Unix-like operating systems based on the Linux kernel

 Linux is typically packaged in a Linux distribution.

 Distributions include the Linux kernel and supporting system software and libraries,
many of which are provided by the GNU Project.
 Many Linux distributions use the word "Linux" in their name, but the Free Software
Foundation uses the name "GNU/Linux" to emphasize the importance of GNU software,
causing some controversy.

FreeBSD

 FreeBSD is an operating system used to power modern servers, desktops, and embedded
platforms.

 A large community has continually developed it for more than thirty years. Its advanced
networking, security, and storage features have made FreeBSD the platform of choice for
many of the busiest web sites and most pervasive embedded networking and storage
devices.

Cosmos

 This is an open source operating system written mostly in programming language C#. Its
full form is C# Open Source Managed Operating System.

 Cosmos did not intend to be a fully fledged operating system but a system that allowed
other developers to easily build their own operating systems.

 It also hid the inner workings of the hardware from the developers thus providing data
abstraction.

FreeDOS

 This was a free operating system developed for systems compatible with IBM PC
computers.

 FreeDOS provides a complete environment to run legacy software and other embedded
systems. It can booted from a floppy disk or USB flash drive as required.

 FreeDos is licensed under the GNU General Public license and contains free and open
source software. So there is no license fees required for its distribution and changes to the
system are permitted.

Phantom OS

 This is an operating system that is based on the concepts on persistent virtual memory
and is code oriented.

 It was mostly developed by Russian developers. Phantom OS is not based on concepts of


famous operating systems such as Unix.

 Its main goal is simplicity and effectiveness in process management.


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
may differ from one operating system to another. These operating system services are
provided for the convenience of the programmer, to make the programming task easier. There
are several different types of services that are provided. Theyare:
 UserInterface
 ProgramExecution
 I/Ooperations
 File Systemmanipulation
 Communication
The below figure 1.4 shows one view of the various operating system services:

Fig 1.11: View of Operating system Services

1. User Interface: Almost all operating systems have a user interface (UI). This interface
can take several forms. One is a command-line interface (CLI), which uses text
commands and a method for entering them (say, a keyboard for typing in commands in
a specific format with specific options). Another is a batch interface, in which
commands and directives to control those commands are entered into files, and those
files are executed. Most commonly, a graphical user interface (GUI) is used. Here, the
interface is a window system with a pointing device to direct I/O, choose from menus,
and make selections and a keyboard to enter text. Some systems provide two or all three
of thesevariations.
2. Program Execution: The system must be able to load a program into memory and run
that program. The program must be able to end its execution, either normally or
abnormally (indicating error).
3. I/O Operations: A running program may require I/O, which may involve a file or an
I/O device. For specific devices, special functions may be desired (such as recording to a
CD or DVD drive or blanking a display screen). For efficiency and protection, users
usually cannot control I/O devices directly. Therefore, the operating system must provide
a means to doI/O.
4. File System Manipulation: The file system is of particular interest. Obviously,
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. Many operating systems provide a variety of file systems,
sometimes to allow personal choice and sometimes to provide specific features or
performancecharacteristics.

5. Communications: There are many circumstances in which one process needs to


exchange information with another process. Such communication may occur between
processes that are executing on the same computer or between processes that are
executing on different computer systems tied together by a computer network.
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
operatingsystem.
6. Error Detection: The operating system needs to be detecting and correcting errors
constantly. Errors may occur in the CPU and memory hardware (such as a memory
error or a power failure), in I/O devices (such as a parity error on disk, a connection
failure on a network, or lack of paper in the printer), and in the user program (such as an
arithmetic overflow, an attempt to access an illegal memory location, or a too-great
use of CPU time). For each type of error, the operating system should take the
appropriate action to ensure correct andconsistent computing.
Another set of operating system functions exists not for helping the user but rather for
ensuring the efficient operation of the system itself. Systems with multiple users can gain
efficiency by sharing the computer resources among theusers.
7. Resource Allocation: When there are multiple users or multiple jobs 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. For instance, in determining how best to use the
CPU, operating systems have CPU- scheduling routines that take into account the speed
of the CPU, the jobs that must be executed, the number of registers available, and other
factors. There may also be routines to allocate printers, USB storage drives, and other
peripheraldevices.
8. Accounting: At times the system needs 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 usagestatistics.
9. 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. Protection involves ensuring that all access
to system resources is controlled. Security of the system from outsiders is also
important. Such security starts with requiring each user to authenticate himself or herself
to the system, usually by means of a password, to gain access to system resources. If a
system is to be protected and secure, precautions must be instituted throughoutit.
User and 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).
 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.
 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.
Graphical User Interfaces

 A second strategy for interfacing with the operating system is through a user friendly
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.
 Historically, Mac OS has not provided a command line interface, always requiring its
users to interface with the operating system using its GUI.

Fig 1.12: User Interface

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 may have to be written using assembly-language instructions.
Example on How System calls is used:
Writing a simple program to read data from one file and copy them to another file.
1. The first input that the program will need is the names of the two files: the input file and
the output file. These names can be specified in many ways, depending on the operating-
system design. One approach is for the program to ask the user for the names. In an
interactive system, this approach will require a sequence of system calls, first to write a
prompting message on the screen and then to read from the keyboard the characters that
define the two files.
2. Once the two file names have been obtained, the program must open the input file and
create the output file. Each of these operations requires another system call. Possible
error conditions for each operation can require additional system calls.
3. When 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 (for example, no more disk space).
4. Finally, after the entire file is copied, the program may close both files (another system
call), write a message to the console or window (more system calls), and finally
terminate normally (the final system call). This system-call sequence is shown in Figure
1.13.
Fig 1.13: Example of how system
calls are used

Types of System Calls:

System calls can be grouped roughly into six major categories. They are:
1. Processcontrol, 4. Informationmaintenance,
2. Filemanipulation, 5. Communications,and
3. Devicemanipulation, 6.Protection.
In each category there are certain types of system calls that are provided. They are as follows:
1. ProcessControl:
 end,abort
 load,execute
 create process, terminateprocess
 get process attributes, set processattributes
 wait fortime
 wait event, signalevent
 allocate and freememory
File Management:
 create file, deletefile
 open, close
 read, write,reposition
 get file attributes, set fileattributes
Device Management:
 request device, releasedevice
 read, write,reposition
 get device attributes, set deviceattributes
 logically attach or detachdevices
Information Management:
 get time or date, set time ordate
 get system data, set systemdata
 get process, file, or deviceattributes
 set process, file, or deviceattributes
Communications
 create, delete communicationconnection
 send, receivemessages
 transfer statusinformation
 attach or detach remotedevices

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 a
debugger: a system program designed to aid the programmer in finding and correcting
errors or bugs to determine the cause of the problem. Under either normal or abnormal
circumstances, the operating system must transfer control to the invoking
commandinterpreter
The command interpreter then reads the next command. In an interactive system, the
command interpreter simply continues with the next command assuming that the user will
issue an appropriate command to respond to anyerror.
If a new job or process is created or a set of process are created, the user should be able to
control its execution. It requires the abilities to determine and reset the attributes of a job or a
process. So get_process_attributes() and set_process_attributes() system calls are used. The
created process may also be terminated using terminate_process() system call.

File Management:
Files can be created and deleted using create() and delete() system calls. 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 usingit.

The same set of operations can be used for directories if there is a directory structure for
organizing file in the file system. For either files or directories various attributes need to be
determined. File attributes include the file name, file type, protection codes, 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() andcopy().

Device Management:
A process may need several resources to execute – main memory, disk drivers, and access
to files and so on. If the resources are available they can be granted, and the control can be
returned to the user process. Otherwise the process has to wait until sufficient resources
areavailable.
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 todevices.
Information Maintenance:
Many system calls exist 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 the
number of current users, the version number of the operating system, 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. A program trace lists each
system call as it is executed. Even microprocessors provide a CPU mode known as single step,
in which a trap is executed by the CPU after every instruction. The trap is usually caught by
adebugger.
Communication:
There are two common models of inter-process communication. They are:
 The message passing modeland
 The Shared memorymodel
1. The Message Passing Model: In the message-passing model, the communicating
processes exchange messages with one another to transfer information. Messages can be
exchanged between the processes either directly or indirectly through a common
mailbox. Before communication can take place, a connection must be opened. The name
of the other communicator must be known. Each computer in a network has a host
name. A host also has a network identifier, such as an IP address. Similarly, each
process has a process name, and this name is translated into anidentifier by which the
operating system can refer to the process. The get hostid() and get processid() system
calls do this translation. 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. The
recipient process usually must give its permission for communication to take place with
an accept_connection() call. Most processes that will be receiving connections are
special-purpose daemons, which are system programs provided for that purpose. They
execute a wait_for_connection() call and are awakened when a connection is made. 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. The close_connection() call terminates the communication.
2. The Shared Memory Model: 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. In general the operating system tries to
prevent one process from accessing another process’s memory Shared memory
requires that two or more processes agree to remove this restriction. They can then
exchange information by reading and writing data in the shared areas. The processes
are also responsible for ensuring that they are not writing to the same location
simultaneously.
Note: Message passing is useful for exchanging smaller amounts of data, because no conflicts
need be avoided. It is also easier to implement than is shared memory for inter-computer
communication. Shared memory allows maximum speed and convenience of communication,
since it can be done at memory transfer speeds when it takes place within a computer.

System programs

 System programs provide an environment where programs can be developed and


executed. In the simplest sense, system programs also provide a bridge between the user
interface and system calls. In reality, they are much more complex. For example: A
compiler is a complex system program.

 The user view of the system is actually defined by system programs and not system calls
because that is what they interact with and system programs are closer to the user
interface.

Fig 1.14: User Interface

In the above image, system programs as well as application programs form bridge between the
user interface and the system calls. So, from the user view the operating system observed is
actually the system programs and not the system calls.

Types of System Programs

1. File Manipulation

These system programs are used to manipulate system files. This can be done using various
commands like create, delete, copy, rename, print etc. These commands can create files, delete
files, copy the contents of one file into another, rename files, print them etc.

2. Status Information

The status information system programs provide required data on the current or past status of
the system. This may include the system date, system time, available memory in system, disk
space, logged in users etc.

3. File Modification

System programs that are used for file modification basically change the data in the file or
modify it in some other way. Text editors are a big example of file modification system
programs.

4. Programming Language Support

These system programs provide additional support features for different programming
languages. Some examples of these are compilers, debuggers etc. These compile a program
and make sure it is error free respectively.

5. Program Loading and Execution

The system programs that deal with program loading and execution make sure that programs
can be loaded into memory and executed correctly. Loaders and Linkers are a prime example
of this type of system programs.

6. Communications

These system programs are needed for system communications such as web browsers. Web
browsers allow systems to communicate and access information from the network as required.

Application Programs

Application programs can perform a wide range of services as per the needs of the users.
These include programs for database systems, word processors, plotting tools, spread sheets,
games, scientific applications etc.

Operating system debugging

Debugging is the process of finding the problems in a computer system and solving them.
There are many different ways in which operating systems perform debugging. Some of these
are

Log Files
The log files record all the events that occur in an operating system. This is done by writing all
the messages into a log file. There are different types of log files. Some of these are given as
follows –

1. Event Logs

These stores the records of all the events that occur in the execution of a system. This is done
so that the activities of all the events can be understood to diagnose problems.

2. Transaction Logs

The transaction logs store the changes to the data so that the system can recover from crashes
and other errors. These logs are readable by a human.

3. Message Logs

These logs store both the public and private messages between the users. They are mostly
plain text files, but in some cases they may be HTML files.

4. Core Dump Files

The core dump files contain the memory address space of a process that terminates
unexpectedly. The creation of the core dump is triggered in response to program crashes by the
kernel. The core dump files are used by the developers to find the program’s state at the time
of its termination so that they can find out why the termination occurred.

The automatic creation of the core dump files can be disabled by the users. This may be done
to improve performance, clear disk space or increase security.

5. Crash Dump Files

In the event of a total system failure, the information about the state of the operating system is
captured in crash dump files. There are three types of dump that can be captured when a
system crashes. These are –

 Complete Memory Dump

The whole contents of the physical memory at the time of the system crash are captured
in the complete memory dump. This is the default setting on the Windows Server
System.
 Kernel Memory Dump

Only the kernel mode read and write pages that are present in the main memory at the
time of the system crash are stored in the kernel memory dump.

 Small Memory Dump

This memory dump contains the list of device drivers, stop code, process and thread
information, kernel stack etc.

System Boot

 Booting the system is done by loading the kernel into main memory, and starting its
execution.

 The CPU is given a reset event, and the instruction register is loaded with a predefined
memory location, where execution starts.

 The initial bootstrap program is found in the BIOS read-only memory.

 This program can run diagnostics, initialize all components of the system, loads and
starts the Operating System loader. (Called boot strapping)

 The loader program loads and starts the operating system.

 When the Operating system starts, it sets up needed data structures in memory, sets
several registers in the CPU, and then creates and starts the first user level program.
From this point, the operating system only runs in response to interrupts.
Fig 1.15: System Boot Process Steps

Here are the steps −

 The CPU initializes itself after the power in the computer is first turned on. This is done
by triggering a series of clock ticks that are generated by the system clock.
 After this, the CPU looks for the system’s ROM BIOS to obtain the first instruction in the
start-up program. This first instruction is stored in the ROM BIOS and it instructs the
system to run POST (Power On Self Test) in a memory address that is predetermined.
 POST first checks the BIOS chip and then the CMOS RAM. If there is no battery failure
detected by POST, then it continues to initialize the CPU.
 POST also checks the hardware devices, secondary storage devices such as hard drives,
ports etc. And other hardware devices such as the mouse and keyboard. This is done to
make sure they are working properly.
 After POST makes sure that all the components are working properly, then the BIOS
finds an operating system to load.
 In most computer system’s, the operating system loads from the C drive onto the hard
drive. The CMOS chip typically tells the BIOS where the operating system is found.
 The order of the different drives that CMOS looks at while finding the operating system
is known as the boot sequence. This sequence can be changed by changing the CMOS
setup.
 After finding the appropriate boot drive, the BIOS first finds the boot record which tells it
to find the beginning of the operating system.
 After the initialization of the operating system, the BIOS copies the files into the
memory. Then the operating system controls the boot process.
 In the end, the operating system does a final inventory of the system memory and loads
the device drivers needed to control the peripheral devices.
 The users can access the system applications to perform various tasks.
Without the system boot process, the computer users would have to download all the software
components, including the ones not frequently required. With the system boot, only those
software components need to be downloaded that are legitimately required and all extraneous
components are not required. This process frees up a lot of space in the memory and
consequently saves a lot of time.

You might also like