0% found this document useful (0 votes)
22 views25 pages

Understanding Operating Systems Basics

An operating system (OS) is a program that serves as an intermediary between users and computer hardware, managing resources and ensuring efficient operation. It can be categorized into single-processor and multiprocessor systems, with various types such as asymmetric and symmetric multiprocessing. The document also discusses computing environments, open-source operating systems, and the history of operating systems, highlighting the significance of Linux as a prominent example of open-source software.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views25 pages

Understanding Operating Systems Basics

An operating system (OS) is a program that serves as an intermediary between users and computer hardware, managing resources and ensuring efficient operation. It can be categorized into single-processor and multiprocessor systems, with various types such as asymmetric and symmetric multiprocessing. The document also discusses computing environments, open-source operating systems, and the history of operating systems, highlighting the significance of Linux as a prominent example of open-source software.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

What is an Operating System?

 A program that acts as an intermediary between a user of a computer and the computer
hardware Operating system goals:
 Execute user programs and make solving user problems easier
 Make the computer system convenient to use
 Use the computer hardware in an efficient manner

Operating System Definition:

 OS is a resource allocator
 Manages all resources
 Decides between conflicting requests for efficient and fair resource use
 OS is a control program
 Controls execution of programs to prevent errors and improper use of the computer No
universally accepted definition
 Everything a vendor ships when you order an operating system” is good approximation
But varies wildly
 “The one program running at all times on the computer” is the kernel. Everything else is
either a system program (ships with the operating system) or an application program

Computer System Structure:

 Computer system can be divided into four components

[Link] – provides basic computing resources CPU, memory, I/O devices

[Link] system - Controls and coordinates use of hardware among various


applications and user

[Link] programs – define the ways in which the system resources are used to solve the
computing problems of the users

[Link] of the users Word processors, compilers, web browsers, database systems, video
games Users People, machines, other computers

Four Components of a Computer System:

UNIT-1 PAGE-2
 Computer architecture means construction/design of a computer. A computer system may be
organized in different ways. Some computer systems have single processor and others have
multiprocessors. So based on the processors used in computer systems, they are categorized
into the following systems.

1. Single-processor system

2. Multiprocessor system

3. Clustered Systems:

Single Processor Systems:

 Some computers use only one processor such as microcomputers (or personal computers PCs).
On a single-processor system, there is only one CPU that performs all the activities in the
computer system.
 A system that has only one general-purpose CPU, is considered as single- processor system.

Multiprocessor Systems:

 In multiprocessor system, two or more processors work together. In this system, multiple
programs (more than one program) are executed on different processors at the same time.
 This type of processing is known as multiprocessing. Some operating systems have
features of multiprocessing.
 UNIX is an example of multiprocessing operating system. Some versions of Microsoft
Windows also support multiprocessing.
 Multiprocessor system is also known as parallel system. Mostly the processors of
multiprocessor system share the common system bus, clock, memory and peripheral
devices. This system is very fast in data processing.
 Types of Multiprocessor Systems: The multiprocessor systems are further divided into two
types;

(i). Asymmetric multiprocessing system

(ii). Symmetric multiprocessing system

Asymmetric Multiprocessing System(AMS):

 The multiprocessing system, in which each processor is assigned a specific task, is known
as Asymmetric Multiprocessing System.
 For example, one processor is dedicated for handling user's requests, one processor is
dedicated for running application program, and one processor is dedicated for running
image processing and so on. In this system, one processor works as master processor,
while other processors work as slave processors.
 The master processor controls the operations of system. It also schedules and distributes
tasks among the slave processors. The slave processors perform the predefined tasks.

Symmetric Multiprocessing System(SMP):

 The multiprocessing system, in which multiple processors work together on the same task,
is known as Symmetric Multiprocessing System.
 In this system, each processor can perform all types of tasks. All processors are treated
equally and no master-slave relationship exists between the processors.

UNIT-1 PAGE-3
Symmetric Multiprocessing Architecture

 For example, different processors in the system can communicate with each other.
Similarly, an I/O can be processed on any processor. However, I/O must be controlled to
ensure that the data reaches the appropriate processor.
 Because all the processors share the same memory, so the input data given to the
processors and their results must be separately controlled. Today all modern operating
systems including Windows and Linux provide support for SMP.

Dual core design with two cores placed on same chip

A recent trend in CPU design is to include multiple computing cores on a single chip. Such
multiprocessor systems are termed multicore. They can be more efficient than multiple chips with
single cores because on-chip communication is faster than between-chip communication

Computer Startup:

 bootstrap program is loaded at power-up or reboot


 Typically stored in ROM or EPROM, generally known as firmware
 Initializes all aspects of system
 Loads operating system kernel and starts execution

Computer System Organization:

 Computer-system operation
 One or more CPUs, device controllers connect through common bus providing access to
shared memory

UNIT-1 PAGE-4
 Concurrent execution of CPU’s and devices competing for memory cycles

A Modern Computer System:

 I/O devices and the CPU can execute concurrently


 Each device controller is in charge of a particular device type
 Each device controller has a local buffer
 CPU moves data from/to main memory to/from local buffers
 I/O is from the device to local buffer of controller
 Device controller informs CPU that it has finished its operation by causing An interrupt

Functions of Operating Systems:

1. Booting Booting is a process of starting the computer operating system starts the computer to
work. It checks the computer and makes it ready to work.

2. Memory Management It is also an important function of operating system. The memory


cannot be managed without operating system. Different programs and data execute in memory at
one time. if there is no operating system, the programs may mix with each other. The system will
not work properly.

3. Loading and Execution A program is loaded in the memory before it can be executed.
Operating system provides the facility to load programs in memory easily and then execute it.

4. Data security Data is an important part of computer system. The operating system protects the
data stored on the computer from illegal use, modification or deletion.

5. Disk Management Operating system manages the disk space. It manages the stored files and
folders in a proper way

6. Process Management CPU can perform one task at one time. if there are many tasks, operating
system decides which task should get the CPU.

7. Device Controlling operating system also controls all devices attached to computer. The
hardware devices are controlled with the help of small software called device drivers.

8. Providing interface It is used in order that user interface acts with a computer mutually. User
interface controls how you input data and instruction and how information is displayed on screen.
The operating system offers two types of the interface to the user:

UNIT-1 PAGE-5
1. Graphical-line interface: It interacts with of visual environment to communicate with the
computer. It uses windows, icons, menus and other graphical objects to issues commands.

2. Command-line interface:it provides an interface to communicate with the computer by typing


commands.

Operating System operations:

 modern operating systems are interrupt driven. If there are no processes to execute, no
I/O devices to service, and no users to whom to respond, an operating system will sit
quietly, waiting for something to happen.
 Events are almost always signaled by the occurrence of an interrupt or a trap.
 A trap (or an exception) is a software-generated interrupt caused either by an error, 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 the
interrupt.
 Since the operating system and the users share the hardware and software resources of the
computer system, we need to make sure that an error in a user program could cause
problems only for the one program running

Dual-Mode and Multimode Operation:

 There are two modes of operation in the operating system to make sure it works correctly.
These are user mode and kernel mode.
 A diagram that illustrates the transition from user mode to kernel mode and back again is
as follows

The following are the modes

[Link] Mode:The system is in user mode when the operating system is running a user application
such as handling a text editor. The transition from user mode to kernel mode occurs when the
application requests the help of operating system or an interrupt or a system call occurs.

 The mode bit is set to 1 in the user mode. It is changed from 1 to 0 when switching from
user mode to kernel mode.

[Link] Mode

 The system starts in kernel mode when it boots and after the operating system is loaded, it
executes applications in user mode. There are some privileged instructions that can only be
executed in kernel mode. These are interrupt instructions, input output management etc. If
the privileged instructions are executed in user mode, it is illegal and a trap is generated.

UNIT-1 PAGE-6
 The mode bit is set to 0 in the kernel mode. It is changed from 0 to 1 when switching from
kernel mode to user mode.

Multimode:

 The concept of modes of operation in operating system can be extended beyond the dual
mode. This is known as the multimode system. In those cases the more than 1 bit is used
by the CPU to set and handle the mode.
 An example of the multimode system can be described by the systems that support
virtualisation. These CPU’s have a separate mode that specifies when the virtual machine
manager (VMM) and the virtualisation management software is in control of the system.
 For these systems, the virtual mode has more privileges than user mode but less than
kernel mode.

Computing Environments:

[Link] Computing Environment

[Link] Computing

[Link] Computing Environment

[Link] Server Computing Environment

[Link]-to-Peer Computing

[Link]

[Link] Computing

[Link] Time Embeded System

What is Computing Environment

 While solving a problem, a computer uses multiple devices. During which the devices can
be arranged in a number of ways to work together towards the solution. As a result, the
devices and components constitute a computing environment

Personal Computing:

 A Personal Computing Environment includes a single machine. Moreover, it incorporates


complete programs on a computer and performs it.
 For example, machines like laptops, mobiles, printers, etc are a part of the Personal
Computing Environment. As a result, this type of computing environment is for single
users to run tasks at home or offices.

Mobile Computing:

 Mobile Computing refers to the type of environment that runs tasks on smartphones and
tablets. Hence, it is computing on portable and lightweight devices.
 Although, compared to other devices, mobile systems lack screen size, memory capacity,
and other traditional functionalities. However, it does provide remote access to multiple
services.

UNIT-1 PAGE-7
 Today, mobile computing environments consist of multiple functions. Hence, it offers
services as good as any other traditional device. Moreover, the two main operating systems
that dominate this market are Apple iOS and Google Android.

Distributed Computing:

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

Client Server Computing:

 Client-Server Computing is a type of environment that incorporates two machines.


Therefore, it includes a client machine and a server machine. Sometimes, the same
machine serves as the client and the server.
 Subsequently, a client requests a resource or service and a server provides the same.
Moreover, a server provides a resource or service to multiple clients simultaneously.
Hence, the communication takes place using a computer network.
 Categorization of Client-Server Computing Environment is into two types:
[Link] Server: It provides the interface to the clients. Hence, it helps communicate
requests to execute tasks.
Meanwhile, the server performs the task and responds with the outcome.
[Link]-Server: The environment provides a file-system interface. Therefore, allowing
clients to create, update, read, and delete files.

Peer to Peer Computing:

 Peer-to-Peer Computing is a type of environment similar to a Distributed type of


Computing Environment. That is to say, there are no differences between clients and
servers in this type of computing environment.
 P2P provides an advantage over traditional client-server environments. That is to say, it
provides services using several nodes throughout the network

Cloud Computing:

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

Real Time Embeded Systems:

 Embedded computers are the most prevalent form of computers in existence. These
devices are found everywhere, from car engines and manufacturing robots to DVDs and
microwave ovens.
 Real time systems are those systems that work within strict time constraints and provide a
worst case time estimate for critical situations. Embedded systems provide a specific
function in a much larger system. When there is an embedded component in a real time
system, it is known as a real time embedded system.

UNIT-1 PAGE-8
Open-Source Operating Systems

 Open-source operating systems are those available in source-code format rather than as
compiled binary code.
 Linux is the most famous opensource operating system, while Microsoft Windows is a
well-known example of the opposite closed-source approach.
 Apple’s Mac OS X and iOS operating systems comprise a hybrid approach. They contain
an open-source kernel named Darwin yet include proprietary, closed-source components
as well
 With the source code in hand, a student can modify the operating system and then compile
and run the code to try out those changesThere are many benefits to open-source operating
systems, including a community of interested (and usually unpaid) programmers who
contribute to the code by helping to debug it, analyze it, provide support, and suggest
changes.

History

 Computer and software companies eventually sought to limit the use of their software to
authorized computers and paying customers.
 Releasing only the binary files compiled from the source code, rather than the source code
itself, helped them to achieve this goal, as well as protecting their code and their ideas
from their competitors
 Another issue involved copyrighted material.
 Operating systems and other programs can limit the ability to play back movies and music
or display electronic books to authorized computers.
 Such copy protection or digital rights management (DRM) would not be effective if the
source code that implemented these limits were published
 Richard Stallman in 1983 started the GNU project to create a free, open-source,
UNIXcompatible operating system.
 In 1985, he published the GNU Manifesto, which argues that all software should be free
and open-sourced. He also formed the Free Software Foundation (FSF) with the goal of
encouraging the free exchange of software source code and the free use of that software.
Rather than copyright its software
 The GNU General Public License (GPL) codifies copy lefting and is a common license
under which free software is released. Fundamentally, GPL requires that the source code
be distributed with any binaries and that any changes made to the source code be released
under the same GPL license.
 GNU's not Unix

Linux

 As an example of an open-source operating system, consider GNU/Linux


 In 1991, a student in Finland, Linus Torvalds, released a rudimentary UNIX-like kernel
using the GNU compilers and tools and invited contributions worldwide.
 The resulting GNU/Linux operating system has spawned hundreds of unique distributions,
or custom builds, of the system
 Major distributions include RedHat, SUSE, Fedora, Debian, Slackware, and Ubuntu.
 Distributions vary in function, utility, installed applications, hardware support, user
interface, and purpose. For example, RedHat Enterprise Linux is geared to large
commercial use
UNIT-1 PAGE-9
 PCLinuxOS is a LiveCD—an operating system that can be booted and run from a CD-
ROM without being installed on a system’s hard disk.
 One variant of PCLinuxOS—called “PCLinuxOS Supergamer DVD”—is a LiveDVD that
includes graphics drivers and games. A gamer can run it on any compatible system simply
by booting from the DVD. When the gamer is finished, a reboot of the system resets it to
its installed operating system.

BSD Linux

 It started in 1978 as a derivative of AT&T’s UNIX. Releases from the University of


California at Berkeley (UCB) came in source and binary form, but they were not
opensource because a license from AT&T was required.
 BSD UNIX’s development was slowed by a lawsuit by AT&T, but eventually a fully
functional, open-source version, 4.4BSD-lite, was released in 1994
 Just as with Linux, there are many distributions of BSD UNIX, including FreeBSD,
NetBSD, OpenBSD, and DragonflyBSD
 Darwin, the core kernel component of Mac OS X, is based on BSD UNIX and is open-
sourced as well.
 Every Mac OS X release has its opensource components posted at that site. The name of
the package that contains the kernel begins with “xnu.”

Solaris

 Solaris is the commercial UNIX-based operating system of Sun Microsystems. Originally,


Sun’s SunOS operating system was based on BSD UNIX. Sun moved to AT&T’s System
V UNIX as its base in 1991
 In 2005, Sun open-sourced most of the Solaris code as the OpenSolaris project. The
purchase of Sun by Oracle in 2009, however, left the state of this project unclear. The
source code as it was in 2005 is still available via a source code browser and for download
at [Link]

Open Source Systems as Learning Tools

 The free software movement is driving legions of programmers to create thousands of


open-source projects, including operating systems.
 Sites like [Link] and [Link]
 provide portals to many of these projects.
 The advantages of free software and open sourcing are likely to increase the number and
quality of open-source projects, leading to an increase in the number of individuals and
companies that use these projects

UNIT-1 PAGE-10
PART-II

System Structures: Operating System Services, User and Operating-System Interface,


systems calls, Types of System Calls, system programs, Operating system Design and
Implementation, Operating system structure, Operating system debugging, System Boot

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.
 These operating system services are provided for the convenience of the programmer, to
make the programming task easier
 The Figure shows one view of the various operating-system services and how they
interrelate.

[Link] Interface : An interface is required to communicate with the user.

 Interface can take several forms


 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).
 batch interface, in which commands and directives to control those commands are
entered into files, and those files are executed
 graphical user interface (GUI) 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 these variations.

[Link] Execution : The system must be able to load a program into memory and to 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 efficiency and protection, users usually cannot control I/O devices directly. Therefore,
the operating system must provide a means to do I/O

UNIT-1 PAGE-11
[Link] System Manipulation : A program is read and then written in the form of directories and
files. These files can be stored on the storage disk for the long term. The OS allows the users to
create and delete files, duplicate these files, and search files and their information or properties.

It also does permission management for these files i.e., allowing or denying access to these
files or directories based on the file ownership.

[Link] detection: Errors may occur in any of the resources like CPU, I/O devices, or memory
hardware. The OS keeps a lookout for such errors, corrects errors when they occur, and makes
sure that the system works uninterruptedly.

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 the users

 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.
 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 reconfigure the system to improve computing services.
 Protection and security : This is to ensure the safety of the system. Thus, user
authentication is required to access a system. It is also necessary to protect a process from
another when multiple processes are running on a system at the same time.
 The OS controls the access to the resources, protects the I/O devices from invalid access,
and provides authentication through passwords.

User and Operating-System Interface

Two important interfaces:

1)Command Interpreter: which allows users to directly enter commands

2)GUI: allows users to interface with the operating system via a graphical user interface

Command Interpreters

 If a computer system is having multiple command interpreters, they are called as “ Shells”.
For example, on UNIX and Linux systems, a user may choose among several different
shells, including the Bourne shell, C shell, Bourne-Again shell, Korn shell, and others.
 Figure below shows the Bourne shell command interpreter being used on Solaris 10

UNIT-1 PAGE-12
 The main function of the command interpreter is to get and execute the user-specified
commands. 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

1st Approach:

 In this 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.

2nd Approach:

 In this case, the command interpreter does not understand the command in any way; it
merely uses the command to identify a file to be loaded into memory and executed. Thus,
the UNIX command to delete a [Link] [Link]
 would search for a file called rm, load the file into memory, and execute it with the
parameter [Link]. The function associated with the rm command would be defined
completely by the code in the file rm.

Graphical User Interfaces :

 A second strategy for interfacing with the operating system is through a user friendly
graphical user interface, or GUI. Here, rather than entering commands directly via a
command-line 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.
 Mobile systems, smartphones and handheld tablet computers typically use a touchscreen
interface. Here, users interact by making gestures on the touchscreen—for example,
pressing and swiping fingers across the screen. Figure below illustrates the touchscreen of
the Apple iPad.

UNIT-1 PAGE-13
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 have to be
written using assembly-language instructions.
 Let’s first use an example to illustrate how system calls are used: writing a simple program
to read data from one file and copy them to another file.
 The first input that the program will need is the names of the two files: the input file and
the output file. 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.
 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. When the program tries
to open the input file, for example, 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 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 (yet another system call). Another
option, in an interactive system, is to ask the user (via a sequence of system calls to output

UNIT-1 PAGE-14
the prompting message and to read the response from the terminal) whether to replace the
existing file or to abort the program.
 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).
 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 below.

 For most programming languages, the run-time support system provides a systemcall
interface that serves as the link to system calls made available by the operating system.
 The system-call interface intercepts function calls in the API and invokes the necessary
system calls within the operating system. Typically, a number is associated with each
system call, and the system-call interface maintains a table indexed according to these
numbers

Handling of user application invoking open() system call

UNIT-1 PAGE-15
 The system call interface then invokes the intended system call in the operating-system
kernel and returns the status of the system call and any return values
 Three general methods are used to pass parameters to the operating system. The simplest
approach is to pass the parameters in registers.
 In some cases, however, there may be more parameters than registers. In these cases, the
parameters are generally stored in a block, or table, in memory, and the address of the
block is passed as a parameter in a register
 Parameters also can be placed, or pushed, onto the stack by the program and popped off
the stack by the operating system. Some operating systems prefer the block or stack
method because those approaches do not limit the number or length of parameters being
passed

Passing parameters as a table

Types of system calls

 System calls can be grouped roughly into six major categories:

1. process control

[Link] manipulation

[Link] manipulation

[Link] maintenance

[Link], and

[Link].

UNIT-1 PAGE-16
System Programs

 System Programming can be defined as the act of building Systems Softwares using
System Programming Languages.
 According to Computer Hierarchy, one which comes at last is Hardware. Then it is
Operating System, System Programs, and finally Application Programs
 System programs, also known as system utilities, provide a convenient environment for
program development and execution.
 They can be divided into these categories
 File management. These programs create, delete, copy, rename, print, dump, list, and
generally manipulate files and directories
 Status information Some programs simply ask the system for the date, time, amount of
available memory or disk space, number of users, or similar status information.
 Others are more complex, providing detailed performance, logging, and debugging
information.
 these programs format and print the output to the terminal or other output devices or files
or display it in a window of the GUI. Some systems also support a registry, which is used
to store and retrieve configuration information
 File modification. Several text editors may be available to create and modify the content
of files stored on disk or other storage devices. There may also be special commands to
search contents of files or perform transformations of the text
 Programming-language support. Compilers, assemblers, debuggers, and interpreters for
common programming languages are often provided with the operating system 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.
 Communications. These programs provide the mechanism for creating virtual
connections among processes, users, and computer systems. They allow users to send
messages to one another’s screens, to browse Web pages, to send e-mail messages, to log
in remotely, or to transfer files from one machine to another.
 Background services. All general-purpose systems have methods for launching certain
system-program processes at boot time. Some of these processes terminate after
completing their tasks, while others continue to run until the system is halted.
Constantly running system-program processes are known as services, subsystems, or
daemons.
UNIT-1 PAGE-17
Operating-System Design and Implementation

 There are many problems that can occur while designing and implementing an operating
system. There are, of course, no complete solutions to such problems, but there are
approaches that have proved successful.

 Operating System Design Goals

 It is quite complicated to define all the goals and specifications of the operating system
while designing [Link] design changes depending on the type of the operating system i.e if
it is batch system, time shared system, single user system, multi user system, distributed
system etc.
 There are basically two types of goals while designing an operating system. These are

[Link] Goals: The operating system should be convenient, easy to use, reliable, safe and fast
according to the users. However, these specifications are not very useful as there is no set method
to achieve these goals.

[Link] Goals:The operating system should be easy to design, implement and maintain. These
are specifications required by those who create, maintain and operate the operating system. But
there is not specific method to achieve these goals as well.

 Operating System Mechanisms and Policies


 There is no specific way to design an operating system as it is a highly creative task.
However, there are general software principles that are applicable to all operating systems
 A subtle difference between mechanism and policy is that mechanism shows how to do
something and policy shows what to do.
 Policies may change over time and this would lead to changes in mechanism. So, it is
better to have a general mechanism that would require few changes even when a policy
change occurs.
 Operating System Implementation

The operating system needs to be implemented after it is designed. Earlier they were written in
assembly language but now higher level languages are used. The first system not written in
assembly language was the Master Control Program (MCP) for Burroughs Computers.

 Advantages of Higher Level Language

There are multiple advantages to implementing an operating system using a higher level
language such as: the code is written more fast, it is compact and also easier to debug and
understand. Also, the operating system can be easily moved from one hardware to another if it is
written in a high level language.

 Disadvantages of Higher Level Language


 Using high level language for implementing an operating system leads to a loss in speed
and increase in storage requirements.
 However in modern systems only a small amount of code is needed for high performance,
such as the CPU scheduler and memory manager.
 Also, the bottleneck routines in the system can be replaced by assembly language
equivalents if required

Operating-System Structure

UNIT-1 PAGE-18
 For efficient performance and implementation an OS should be partitioned into separate
subsystems, each with carefully defined tasks, inputs, outputs, and performance
characteristics. These subsystems can then be arranged in various architectural
configurations

1. Simple Structure

2. Monolithic Structure

3. Layered Approach

4. Micro kernels

5. Modules

6. Hybrid Systems

Simple Structure

 Many operating systems do not have well-defined structures. Frequently, such systems
started as small, simple, and limited systems and then grew beyond their original scope
 MS-DOS 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
 has no distinction between user and kernel modes, allowing all programs direct access to
the underlying hardware
 MS-DOS was 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.

Monolithic Structure

 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.
 We can view the traditional UNIX operating system as being layered to some extent
UNIT-1 PAGE-19
 This monolithic structure was difficult to implement and maintain

Layered Approach

 Another approach is to break the OS into a number of smaller layers, each of which rests
on the layer below it, and relies solely on the services provided by the next lower layer.
 This approach allows each layer to be developed and debugged independently, with the
assumption that all lower layers have already been debugged and are trusted to deliver
proper services.
 The problem is deciding what order in which to place the layers, as no layer can call upon
the services of any higher layer
 Layered approaches can also be less efficient, as a request for service from a higher layer
has to filter through all lower layers before it reaches the HW, possibly with significant
processing at each step.

Microkernels

 The basic idea behind micro kernels is to remove all non-essential services from the
kernel, and implement them as system applications instead, thereby making the kernel as
small and efficient as possible.
 Most microkernels provide basic process and memory management, and message passing
between other services, and not much more.

UNIT-1 PAGE-20
 Security and protection can be enhanced, as most services are performed in user mode, not
kernel mode.
 System expansion can also be easier, because it only involves adding more system
applications, not rebuilding a new kernel.
 Mach was the first and most widely known microkernel, and now forms a major
component of Mac OSX.
 Windows NT was originally microkernel, but suffered from performance problems relative
to Windows 95. NT 4.0 improved performance by moving more services into the kernel,
and now XP is back to being more monolithic.
 Another microkernel example is QNX, a real-time OS for embedded systems.

Modules

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

UNIT-1 PAGE-21
Hybrid Systems

 Most Operating Systems today do not strictly adhere to one architecture, but are hybrids of
several.
 three hybrid systems:
 the Apple Mac OS X operating system
 and the two most prominent mobile operating systems—iOS and Android.

Mac OS X

 The Apple Mac OS X operating system uses a hybrid 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
interprocess 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 loadable modules

Fig: Mac OS X Structure

 The core services layer provides a variety of features, including support for cloud
computing and databases. The bottom layer represents the core operating system, which is
based on the kernel environment

UNIT-1 PAGE-22
Architecture of APPLE IOS

Android

 The Android operating system was designed by the Open Handset Alliance and was
developed for Android smartphones and tablet computers.
 Android runs on a variety of mobile platforms and is open-sourced, partly explaining its
rapid rise in popularity.
 Android is similar to iOS in that 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 Linux releases

Operating System Debugging

 debugging is the activity of finding and fixing errors in a system, both in hardware and in
software.
 Performance problems are considered bugs, so debugging can also include performance
tuning, which seeks to improve performance by removing processing bottlenecks

Failure Analysis

 If a process fails, most operating systems write the error information to a log file to alert
system operators or users that the problem occurred.

UNIT-1 PAGE-23
 The operating system can also take a core dump—a capture of the memory of the
process— and store it in a file for later analysis.
 Debugging user-level process code is a challenge. Operating-system kernel debugging is
even more complex because of the size and complexity of the kernel, its control of the
hardware, and the lack of user-level debugging tools
 A failure in the kernel is called a crash. When a crash occurs, error information is saved to
a log file, and the memory state is saved to a crash dump.
 Consider that a kernel failure in the file-system code would make it risky for the kernel to
try to save its state to a file on the file system before rebooting
 A common technique is to save the kernel’s memory state to a section of disk set aside for
this purpose that contains no file system
 If the kernel detects an unrecoverable error, it writes the entire contents of memory, or at
least the kernel-owned parts of the system memory, to the disk area.
 When the system reboots, a process runs to gather the data from that area and write it to a
crash dump file within a file system for analysis

Kernighan’s Law

 “Debugging is twice as hard as writing the code in the first place. Therefore, if you write
the code as cleverly as possible, you are, by definition, not smart enough to debug it.”

Performance Tuning

 performance tuning seeks to improve performance by removing processing bottlenecks.


 To identify bottlenecks, we must be able to monitor system performance.
 Thus, the operating system must have some means of computing and displaying measures
of system behavior.
 the operating system does this by producing trace listings of system behavior
 One approach is for the system to record important events into log files, which can then be
analyzed by other tools.
 These traces can also be used to evaluate how a proposed new system would perform
under the same workload
 Traces also can help people to find errors in operating-system behavior.
 Another approach is to provide utilities that will report system status upon demand, such
as the unix "top" command
 The Windows Task Manager is a similar tool for Windows systems. The task manager
includes information for current applications as well as processes, CPU and memory
usage, and networking statistics.

UNIT-1 PAGE-24
DTrace

 DTrace is a special facility for tracing a running OS, developed for Solaris 10.
 DTrace adds "probes" directly into the OS code, which can be queried by "probe
consumers".
 Probes are removed when not in use, so the DTrace facility has zero impact on the system
when not being used, and a proportional impact in use.
 Consider, for example, the trace of an ioctl system call as shown in Figure
 In computing, ioctl is a system call for device-specific input/output operations and other
operations which cannot be expressed by regular system calls
 Example: It takes a parameter specifying a request code; the effect of a call depends
completely on the request code. Request codes are often device-specific. For instance, a
CD-ROM device driver which can instruct a physical device to eject a disc would provide
an ioctl request code to do so
 Probe code is restricted to be "safe", ( e.g. no loops allowed ), and to use a minimum of
system resources.
 When a probe fires, enabling control blocks, ECBs, are performed, each having the
structure of an if-then block
 When a consumer terminates, the ECBs associated with that consumer are removed. When
no more ECBs remain interested in a particular probe, then that probe is also removed.
 Use of DTrace is restricted, due to the direct access to ( and ability to change ) critical
kernel data structures.
 Because DTrace is open-source, it is being adopted by several UNIX distributions. Others
are busy producing similar utilities.

UNIT-1 PAGE-25
System Boot

 The procedure of starting a computer by loading the kernel is known as booting the
system.
 On most computer systems, a small piece of code known as the bootstrap program or
bootstrap loader locates the kernel, loads it into main memory, and starts its execution
 Some computer systems, such as PCs, use a two-step process in which a simple bootstrap
loader fetches a more complex boot program from disk, which in turn loads the kernel
 When a CPU receives a reset event—for instance, when it is powered up or rebooted—the
instruction register is loaded with a predefined memory location, and execution starts
there.
 At that location is the initial bootstrap program. This program is in the form of read-only
memory (ROM), because the RAM is in an unknown state at system startup. ROM is
convenient because it needs no initialization and cannot easily be infected by a computer
virus
 The bootstrap program can perform a variety of tasks. Usually, one task is to run
diagnostics to determine the state of the machine. If the diagnostics pass, the program can
continue with the booting steps.
 It can also initialize all aspects of the system, from CPU registers to device controllers and
the contents of main memory. Sooner or later, it starts the operating system
 Some systems—such as cellular phones, tablets, and game consoles—store the entire
operating system in ROM. Storing the operating system in ROM is suitable for small
operating systems, simple supporting hardware, and rugged operation.
 A problem with this approach is that changing the bootstrap code requires changing the
ROM hardware chips. Some systems resolve this problem by using erasable
programmable read-only memory (EPROM), which is readonly except when explicitly
given a command. All forms of ROM is also known as firmware
 For large operating systems (including most general-purpose operating systems like
Windows, Mac OS X, and UNIX) or for systems that change frequently, the bootstrap
loader is stored in firmware, and the operating system is on disk.
 In this case, the bootstrap runs diagnostics and has a bit of code that can read a single
block at a fixed location (say block zero) from disk into memory and execute the code
from that boot block.
 The program stored in the boot block may be sophisticated enough to load the entire
operating system into memory and .
 GRUB is an example of an open-source bootstrap program for Linux systems. All of the
disk-bound bootstrap, and the operating system itself, can be easily changed by writing
new versions to disk.
 A disk that has a boot partition is called a boot disk or system disk.
 Now that the full bootstrap program has been loaded, it can traverse the file system to find
the operating system kernel, load it into memory, and start its execution. It is only at this
point that the system is said to be running.

UNIT-1 PAGE-26

You might also like