Unit 1
Unit 1
3
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
The hardware- the central processing unit (CPU),the memory, the 1.1.2 System View
input/output (I/O) devices- provide the basic computingresources for 1. From the computer’s point of view, the operating system is the
the system. program most intimately involved with the hardware.
The application programs- such as word processors, spreadsheets, 2. It can be viewed as
compilers, and Web browsers—define the ways in which these Aresource allocator
resources are used to solve users’ computing problems. A control program
The operating system controls the hardware and coordinates its use 3. Resource allocator:The operating system acts as the manager of
among the various application programs for the various user the following resources and decide how to allocate them to
1.1.1 User View specific programs and users so that it can operate the computer
The user’s view of the computer varies according to the interface system efficiently
beingused. CPU time
Personal Computer - a system designed for one user. The goal here is memory space
to maximize the work (or play) that the user is performing. The file-storage space
operating system is designed mostly for ease of use, with some I/O devices
attention paid to performance and none paid to resource utilization. 4. Control program: An operating system is a control program. It
Mainframe or Minicomputer- Other users are accessing the same manages the execution of user programs to prevent errors and
computer through other terminals. These users share resources and improper use of the computer. It is especially concerned with the
may exchange information. The operating system in such cases is operation and control of I/O devices.
designed to maximize resource utilization, to assure that all available 1.2Basic Elements
CPU time, memory, and I/O are used efficiently and that no individual There are four main structural elements;Figure 1.2 depicts these top-level
user takes more than the fair share. components.
Workstations-connected to networks ofother workstations and servers. 1. Processor
These users have dedicated resources attheir disposal, but they also 2. Main memory
share resources such as networking and servers,including file, 3. I/O modules
compute, and print servers. Therefore, their operating system 4. System bus
isdesigned to compromise between individual usability and resource 1. Processor:
utilization. Controls the operation of the computer and performs its data
processing functions.
4
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
When there is only one processor, it is often referred to as the It contains internal buffers for temporarily holding data until
central processing unit (CPU). they can be sent on.
One of the processor’s functions is to exchange data with memory.For this 4. System bus:
purpose, it makes use of two internal (to the processor) registers: Provides for communication among processors, main memory, and
Memory address register (MAR)- specifies the address in I/O modules.
memory for the next read or write;
Memory buffer register (MBR)- contains the data to be written
into memory or which receives the data read from memory.
I/O address register (I/OAR)- a particular I/O device.
I/O buffer register (I/OBR)- used for the exchange of data
between an I/O module and the processor.
2. Main memory:
It is also referred to as real memory or primary memory.Stores data
and programs.
This memory is volatile in nature, when the computer is shut
down; the contents of the memory are lost.
The contents of disk memory are retained even when the computer
system is shut down.
Consists of a set of locations, defined by sequentially numbered
addresses. Figure 1.2 Computer Components: Top-Level View
Each location contains a bit pattern that can be interpreted as either
an instruction or data. 1.3 Instruction Execution
3. I/O modules: A program to be executed by a processor consists of a set of
Transfers data from external devices to processor and memory, and instructions storedin memory. The processing required for a single
vice versa. instruction is called an instruction cycle. Program execution consists of
The external environment consists of a variety of devices, repeating the process of instruction fetch and instruction execution. In its
including secondary memory devices (e.g., disks), communications simplest form, instruction processing consists of two steps: The processor
equipment, and terminals. reads (fetches) instructions from memory one at a time and executes
eachinstruction.
5
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
6
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
requestedfunction (or periodically check the status, or poll, • Meanwhile, the external device is busy accepting data from computer
the I/O device). memory and printing it.
• The programmight wait by simply repeatedly performing a • This I/O operation is conducted concurrently with the execution of
test operation to determine ifthe I/O operation is done. instructions in the user program.
iii. A sequence of instructions, labeled 5 in the figure1.3,
• To complete the operation.This may include setting a flag
indicating the success or failure of the operation.
3. The dashed line represents the path of execution followed by the
processor and the sequence in which instructions are executed.
4. Thus, after the first WRITE instruction is encountered, the user
program is interrupted and execution continues with the I/O program.
5. After the I/O program execution is complete, execution resumes in the
user program immediately following the WRITE instruction.
6. Because the I/O operation may take a relatively long time to complete,
the I/O program is hung up waiting for the operation to complete;
hence, the user program is stopped at the point of the WRITE call for
some considerable period of time.
Interrupts and the Instruction Cycle
i.With interrupts, the processor can be engaged in executing other Figure 1.3 (a) No interrupts (b) Interrupts; short I/O wait (c) long I/O wait
instructions while an I/O operation is in progress. • When the external device becomes ready to be serviced, that is, when it
ii. Consider the flow of control in Figure 1.3b. is ready to accept more data from the processor, the I/O module for
• As the user program reaches a point at which it makes a system call in that external device sends an interrupt request signal to the processor.
the form of a WRITE call. • The processor responds by suspending operation of the current
• The I/O program that is invoked in this case consists only of the program; branching off to a routine to service that particular I/O device,
preparation code and the actual I/O command. known as an interrupt handler; and resuming the originalexecution after
• After these few instructions have been executed, control returns to the the device is serviced. The points at which such interrupts occur are
user program. indicated by × in Figure.
7
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
Instruction Cycle 2. The processor finishes execution of the current instruction before
i. To accommodate interrupts, an interrupt stage is added to the responding to the interrupt.
instruction cycle, as shown in Figure 1.4. 3. The processor tests for a pending interrupt request, determines that
ii. In the interrupt stage, the processor checks to see if any interrupts have there is one, and sends an acknowledgment signal to the device
occurred, indicated by the presence of an interrupt signal. that issued the interrupt. The acknowledgment allows the device to
remove its interrupt signal.
iii. If no interrupts are pending, the processor proceeds to the fetch stage
4. The processor next needs to prepare to transfer control to the
and fetches the next instruction of the current program. interrupt routine.
iv. If an interrupt is pending, the processor suspends execution of the a. To begin, it saves information needed to resume the current
current program and executes an interrupt handler routine and it is a program at the point of interrupt.
part of the OS. b. The minimum information required is the program status
v. When the interrupt-handler routine is completed, the processor can word (PSW) and the location of the next instruction to be
resume execution of the user program at the point of interruption. executed, which is contained in the program counter (PC).
These can be pushed onto a control stack
5. The processor then loads the program counter with the entry
location of the interrupt-handling routine that will respond to this
interrupt.
When an I/O device completes an I/O operation, the following sequence of
software events occurs:
• Once the program counter has been loaded, the processor proceeds
to the next instruction cycle, which begins with an instruction
Figure 1.4 Instruction Cycle with interrupts fetch.
6. The program counter and PSW relating to the interrupted program
Interrupt Processing
have been saved on the control stack. The interrupt handler will
An interrupt triggers a number of events, both in the processor hardware
begin by saving the contents of all registers on the stack.
and in software. Figure 1.10 shows a typical sequence. When an I/O
7. The interrupt handler may now proceed to process the interrupt.
device completes an I/O operation, the following sequence of hardware
a. This includes an examination of status information relating
events occurs:
to the I/O operation or other event that caused an interrupt.
1. The device issues an interrupt signal to the processor.
b. It may also involve sending additional commands or
acknowledgments to the I/O device.
8
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
9
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
10
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
Main memory is usually extended with a higher-speed, smaller These implement frequently used functions that assist in program
cache. The cache is not usually visible to the programmer or,indeed, to the creation, the management of files, and the control of I/O
processor. It is a device for staging the movement of data between main devices.
memory and processor registers to improve performance. A programmer will make use of these facilities in developing an
Data are stored more permanently on external mass storage application, and the application, while it is running, will invoke the
devices, of which the most commonare hard disk and removable media, utilities to perform certain functions.
such as removable disk, tape, and optical storage. External, nonvolatile The most important collection of system programs comprises the
memory is also referred to as secondary memory or auxiliary memory. OS.
1.6 Operating system overview-objectives and functions The OS masks the details of the hardware from the programmer and
Objectives provides the programmer with a convenient interface for using the
1. Convenience: An OS makes a computer more convenient to use. system.
2. Efficiency: An OS allows the computer system resources to be
used in an efficient manner.
3. Ability to evolve: An OS should be constructed in such a way as
to permit the effective development, testing, and introduction of
new system functions without interfering with service.
The Operating System as a User/Computer Interface
The end user views a computer system in terms of a set of
applications.
An application can be expressed in a programming language and is
developed by an application programmer.
If an application program is developed as a set of machine Figure1.8 Computer Hardware and Software Structure
instructions that is completely responsible for controlling the Operating System Services
computer hardware and is very complex undertaking. 1. Program development
To ease this chore, a set of system programs is provided. OS provides a variety of facilities and services, such as editors and
Some of these programs are referred to as utilities, or library debuggers, to assist the programmer in creating programs.
programs.
11
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
These services are in the form of utility programs that, while 6. Error detection and response
notstrictly part of the core of the OS, are supplied with the OS and A variety of errors can occur while a computersystem is
are referred to as application program development tools. running.
2. Program execution In each case,the OS must provide a response that clears the
The OS handles the scheduling duties for the user. error condition with the leastimpact on running applications.
A number of steps need to be performed to execute aprogram. The response may range from ending the program that caused
Instructions and data must be loaded into main memory, the error, to retrying the operation, to simply reporting the
I/O devices and files must be initialized, and other error to the application.
resources must be prepared. 7. Accounting
3. Access to I/O devices A good OS will collect usage statistics for various resources and
Each I/O device requires its own peculiar set of instructions or monitor performance parameters such as response time.
control signals for operation. On any system, this information is useful in anticipating the need
The OS provides a uniform interface suchthat programmers for future enhancements and intuning the system to improve
can access devices using simple reads and writes. performance.
4. Controlled access to files On a multiuser system, the information can be used for billing
The OS must reflect a detailed understanding of the nature of purposes.
the I/O device (disk drive, tape drive) and also the structure of Figure1.8 also indicates three key interfaces in a typical computer system:
the data contained in the files on the storage medium. 1. Instruction set architecture (ISA)
For a system with multiple users, the OS provides protection The ISA defines the repertoire of machine language instructions
mechanisms to control access to the files. that a computer can follow.
5. System access Application programs and utilities may access the ISA directly.
For shared or public systems, the OS controls access to For these programs, a subset of the instruction repertoire is
thesystem as a whole and to specific system resources. available (user ISA).
The access function must provide protection of resources and The OS has access to additional machine language instructions that
data from unauthorized users and must resolve conflicts for deal with managing system resources (system ISA).
resource contention. 2. Application binary interface (ABI)
It defines a standard for binary portability across programs.
12
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
It also defines the system call interface to the operating system and vii The OS decides when an I/O device can be used by a program in
the hardware resources and services available in asystem through execution and controls access to and use of files.
the user ISA. viii The processor itself is a resource, and the OS must determine how
3. Application programming interface (API) much processor time is to be devoted to the execution of a particular
UserISA supplemented with high-level language (HLL) library user program.
calls provides a program access to the hardware resources and
services available in a system.
Any system calls are usually performed through libraries.
Using an API enables application software to be ported easily,
through recompilation, to other systems that support the same API.
The Operating System as Resource Manager
i A computer is a set of resources for the movement, storage, and
processing of data and for the control of these functions.
ii The OS is responsible for managing theseresources.
iii OS acts as a controlmechanism in two respects:
The OS functions in the same way as ordinary computer
software; that is, it isa program or suite of programs
executed by the processor.
The OS frequently relinquishes control and must depend Figure 1.9The Operating System as Resource Manager
on the processor to allow it to regain control. ix In the case of a multiple-processor system, this decision must span all
iv A portion of the OS is in main memory. This includes the kernel, or of the processors.
nucleus, which contains 1.7Evolution of Operating System
the most frequently, used functions in the OS , 1.7.1 Serial Processing
at a given time, other portions of the OS currently in use.
i. With the earliest computers, the programmer interacted directly
v The remainder of main memory contains user programs and data.
with the computer hardware. These machines are called bare
vi The memory management hardware in the processor and the OS
machine as they don't have OS.
jointly control the allocation of main memory.
13
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
ii. These computers were run from a console consisting of display If an error occur user had to go the beginning of the set up
lights, toggle switches, some form of input device, and a printer. sequence. Thus, a considerable amount of time is spent in setting
iii. Programs in machine code were loaded via the input device (e.g., a up the program to run.
card reader). If an error halted the program, the error condition was This mode of operation is termed serial processing, reflecting the
indicated by the lights. fact that users have access to the computer in series.
iv. If the program proceeded to a normal completion, the output 1.7.2 Simple Batch Processing
appeared on the printer. To maximize processor utilization, the concept of a batch OS was
v. These systems presented two major problems. developed.
Scheduling The central idea behind the simple batch-processing scheme is the
Set up time use of a piece of software known as the monitor.
Scheduling The user no longer has direct access to the processor. Instead, the
Most installations used a hardcopy sign-up sheet to reserve user submits the job on cards or tape to a computer operator, who
computer time. batches the jobs together sequentially and places the entire batch
A user could sign up for a block of time in multiples of a half hour on an input device, for use by the monitor.
or so. Each program is constructed to branch back to the monitor when it
A user might sign up for an hour and finish in 45 minutes; this completes processing, at which point the monitor automatically
would result in wasted computer processing time. begins loading the next program.
The user might run into problems, not finish in the allotted time, Monitor point of view
and be forced to stop before resolving the problem. It controls the sequence of events.For this purpose, much of the
Set up time monitor must always be in main memory and available for
A single program is called job and it involves: execution. That portion is referred to as the resident monitor.
i. Loading compiler and source program into memory The rest of the monitor consists of utilities and common functions
ii. Saving the compiled program (object code) that are loaded as subroutines to the user program at the beginning
iii. Loading and linking together object program and common of any job that requires them.
functions The monitor reads in jobs one at a time from the input device. As it
Each of these steps involves the mounting or dismounting tapes on is read in, the current job is placed in the user program area, and
setting up punch cards. control is passed to this job.
14
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
15
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
Privileged instructions:
i. Certain machine level instructions are designated privileged and
can be executed only by the monitor.
ii. If the processor encounters such an instruction while executing a
user program, an error occurs causing control to be transferred to
the monitor.
iii. Among the privileged instructions are I/O instructions, so that the
monitor retains control of all I/O devices.
iv. Considerations of memory protection and privileged instructions
lead to the concept of modes of operation.
A user program executes in a user mode, in which certain areas Figure 1.11 Memory layout for a multiprogramming system
of memory are protected from the user’s use and in which certain The operating system picks and begins to execute one of the jobs
instructions may not be executed. in the memory.
The monitor executes in a system mode, or what has come to be Eventually, the job may have to wait for some task, such as an
called kernel mode, in which privileged instructions may be I/O operation, to complete.
executed and in which protected areas of memory may be The operating system simply switches to, and executes, another
accessed. job.
1.7.3Multiprogrammed Systems When that job needs to wait, the CPU is switched to another job,
i. Multiprogramming increases CPU utilization by organizing jobs so and so on.
thatthe CPU always has one to execute. Eventually, the first job finishes waiting and gets the CPU back.
ii. The idea is as follows: As long as at least one job needs to execute, the CPU is never
The operating system keeps several jobs in memory idle.
simultaneously (Figure 1.11). Multiprogrammed operating systems are therefore fairly sophisticated.
This set of jobs is a subset of the jobs kept in thejob pool- If several jobs are ready to be brought into memory, and if there is
since the number of jobs that can be kept simultaneously in not enough room for all of them, then choosing one among them
memoryis usually much smaller than the number of jobs that is called job scheduling.
can be in the job pool. When the operating system selects a job from the job pool, it
loads that job into memory for execution. Having several
16
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
programs in memory at the same time requires some form of Must also provide a file system. The file system resides on
memory management. a collection of disks; hence, disk management mustbe
if several jobs are ready to run at the same time, the system must provided.
choose among them. Making this decision is CPU scheduling. Provides a mechanism for concurrent execution, which
1.7.4 Time-Sharing Systems requires sophisticated CPU-scheduling schemes.
Time sharing (or multitasking) is a logical extension of To ensure orderly execution, the system must provide
multiprogramming. mechanisms for job synchronization and communication
The CPU executes multiple jobs by switching among them, but the It may ensure that jobs do not get stuck in a deadlock,
switches occur so frequently that the users can interact with each forever waiting for one another.
program while it is running. 1.8 Computer System Organization
A time-shared operating system allows many users to share the Computer-System Operation
computer simultaneously 1. A modern general-purpose computer system consists of one or
i. An interactive (or hands-on) computer system provides direct more CPUs and a number of device controllers connected through
communication between the user and the system. a common bus that provides access to shared memory (Figure
ii. The user gives instructions to the operating system or to a program 1.12).
directly, using a keyboard or a mouse, and waits for immediate 2. Each device controller is incharge of a specific type of device (for
results. example, disk drives, audio devices, or video displays).
iii. A time-shared operating system uses CPU scheduling and 3. The CPU and the device controllers can execute in parallel,
multiprogramming to provide each user with a small portion of a competing for memory cycles.
time-shared computer. 4. To ensure orderly access to the shared memory,a memory
iv. Each user has at least one separate programin memory. A program controller synchronizes access to the memory.
loaded into memory and executing is commonly referred to as a 5. Bootstrap program- the initial program that run when a computer
process. is started or rebooted.
v. Time-Sharing Systems 6. It is stored within the computer hardware in read-only memory
Provides virtual memory support for memory (ROM) or electrically erasable programmable read-only memory
management. (EEPROM), known by the general term firmware.
7. It initializes all aspects of the system, from CPU registers to device
controllers to memory contents.
17
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
8. The bootstrap program must know how to load the operating 17. The interrupt service routine executes; on completion, the CPU
system and how to start executing that system. resumes theinterrupted computation.
9. To accomplish this goal, the bootstrap program must locate the Storage Structure
operating-system kernel and load it into memory. 1. The CPU can load instructions only from memory, so any
10. Once the kernel is loaded and executing, it can start providing programs to run must be stored there.
services to the system and its users. 2. All forms of memory provide an array of bytes. Each byte has its
11. Once this phase is complete, the system is fully booted, and the own address.
system waits for some event to occur. 3. Main memory or RAM
12. The occurrence of an event is usually signaled by an interrupt Rewritablememory.
from either the hardware or the software.
It is implemented in a semiconductor technology called
13. Hardware may trigger an interrupt at any time by sending a signal
dynamic random-access memory (DRAM).
to the CPU, usually by way of the system bus.
It is usually too small to store all needed programs and data
permanently.
It is a volatile storage device that loses its contents when
power is turned off or otherwise lost.
4. Secondary storage
An extension of main memory used to hold large quantities
of data permanently.
The most common secondary-storage device is a magnetic
disk, whichprovides storage for both programs and data.
Most programs (system and application) are stored on a
Figure1.12 a modern Computer System disk until they are loaded into memory.
14. Software may trigger an interrupt by executing a special operation Many programs then use the disk as both the source and the
called a system call (also called a monitor call). destination of their processing.
15. When the CPU is interrupted, it stops what it is doing and 5. Interaction is achieved through a sequence of load or store
immediatelytransfers execution to a fixed location. instructions to specific memory addresses.
16. The fixed location usually containsthe starting address where the
service routine for the interrupt is located.
18
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
6. The load instruction moves a byte or word from main memory to 10. The device driver then returns control to the operating system,
an internal register within the CPU, whereas the store instruction possibly returning the data or a pointer to the data if the operation
moves the content of a register to main memory. was a read.
I/O Structure 11. For other operations, the device driver returns status information.
1. A general-purpose computer system consists of CPUs and multiple This form of interrupt-driven I/O is fine for moving small amounts
device controllers that are connected through a common bus.Each of data but can produce high overhead when used for bulk data
device controller is in charge of a specific type of device. movement such as disk I/O.
2. Depending on the controller, more than one device may be 12. To solve this problem, direct memory access (DMA) is used.
attached. After setting up buffers, pointers, and counters for the I/O device,
3. For instance, seven or more devices can be attached to the small the device controller transfers an entire block of data directly to or
computer-systems interface (SCSI) controller. from its own buffer storage to memory, with no intervention by the
4. A device controller maintains some local buffer storage and a set CPU.
of special-purpose registers. 13. Only one interrupt is generated per block, to tell the device driver
5. The device controller is responsible for moving the data between that the operation has completed, rather than the one interrupt per
the peripheral devices that it controls and its local buffer storage. byte generated for low-speed devices.
6. Operating systems have a device driverfor each device controller. 14. While the device controller is performing these operations, the
CPU is available to accomplish other work.
This device driver understands the device controller and provides
1.9 Operating System Structure
the rest of the operating system with a uniform interface to the Operating-System Structure
device. 1. Simple Structure
7. To start an I/O operation, the device driver loads the appropriate 2. Layered Approach
registers within the device controller. 3. Microkernels
8. The device controller, in turn, examines the contents of these 4. Modules
registers to determine what action to take (such as “read a character 5. Hybrid Systems
from the keyboard”). Mac OS
9. The controller starts the transfer of data from the device to its local iOS
buffer. Once the transfer of data is complete, the device controller Android
informs the device driver via an interrupt that it has finished its
operation.
19
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
21
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
MacOS uses the Aqua user interface, which is designed for a Much of the functionality provided by Mach is available through
mouse or trackpad. kernel abstractions, include tasks a Mach process, threads,
iOS uses the Springboard user interface, which is designed for memory objects, and ports.
touch devices. The kernel environment provides an I/O kit for development of
Application frameworks layer device drivers and dynamically loadable modules (which macOS
Includes the Cocoa and Cocoa Touch frameworks, which provide refers to as kernel extensions or kexts).
an API for the Objective-C and Swift programming languages.
Cocoa is used for developing macOS applications
Cocoa Touch is used by iOS to provide support for hardware
features unique to mobile devices, such as touch screens.
Core frameworks.
o This layer defines frameworks that support graphics and
media including, Quicktime and OpenGL.
Kernel environment.
o This environment, also known as Darwin, includes the
Mach microkernel and the BSD UNIX kernel. Figure1.17 the Mac OS and iOS structure.
Darwin is a layered system that consists primarily of the Mach 5.2 Android
microkernel and the BSD UNIX kernel. Similar stack to IOS
Darwin provides two system-call interfaces: Mach system calls Based on Linux kernel but modified
(known as traps) and BSD system calls (which provide POSIX o Provides process, memory, device-driver management
functionality). o Adds power management
The interface to these system calls is a rich set of libraries that Runtime environment includes core set of libraries and Dalvik
includes not only the standard C library but also libraries that virtual machine
provide networking, security, and programming language o Apps developed in Java plus Android API
support Java class files compiled to Java bytecode then
translated to executable than runs in Dalvik VM
23
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
Hardware abstraction layer or HAL Android can run on an almost o Media Framework: provides by packet video. all audio and
unlimited number of hardware devices, Google has chosen to video codec, AAC, JPEG, MP3
abstract the physical hardware.
By abstracting all hardware, such as the camera, GPS chip, and
other sensors, the HAL provides applications with a consistent
view independent of specific hardware.
This feature, of course, allows developers to write programs that
are portable across different hardware platforms
The standard C library used by Linux systems is the GNU C
library (glibc).
Google instead developed the Bionic standard C library for
Android.
Not only does Bionic have a smaller memory footprint than glibc,
but it also has been designed for the slower CPUs that characterize
mobile devices. Figure 1.19 Architecture of Google’s Android.
At the bottom of Android’s software stack is the Linux kernel. 1.10System Calls
Google has modified the Linux kernel used in Android in a variety 1. System calls provide an interface between the processes and the
of areas to support the special needs of mobile systems, such as operating system.
power management. 2. These calls are generally available as routines written in C, C++, and
certain low-level assembly-language instructions.
It has also made changes in memory management and allocation
3. Application developers design programs according to an application
and has added a new form of IPC known as Binder.
programming interface (API).
Libraries include frameworks for
4. The API specifies a set of functions that are available to an application
o Written in C/C++-smaller libc,
programmer, including the parameters that are passed to each function
o web browser (webkit):open source browser engine.
and the return values the programmer can expect.
o SQLite : core for data storage.
5. A programmer accesses an API via a library of code provided by the
o Surface Manager: Composing different drawing surfaces in
operating system.
on the screen.
6. Each operating system has its own name for each system call.
o OpenGL-OpenGL takes care of 3D graphics library
24
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
7. The functions that make up an API typically invoke the actual system
calls on behalf of the application programmer.
8. An application programmer prefers programming according to an API
rather than invoking actual system calls for beneficial concern of
program portability.
9. Programmers expect the program to compile and run on any system
that supports the same API whereas the actual system calls are more
detailed and difficult to work.
10. Most programming languages, the run-time support system provides a Figure 1.20Passing of parameters as a table.
system call interface that serves as the link to system calls made 1.10.1 Types of System Calls
available by the operating system. System calls can be grouped roughly into six major categories:
11. The system-call interface intercepts function calls in the APIand Processcontrol
invokes the necessary system calls within the operating system. File manipulation
12. A number is associated with each system call, and the system-call Device manipulation
interface maintains a table indexed according to these numbers. Information maintenance
13. The system call interface then invokes the intended system call in the Communications
operating-system kernel andreturns the status of the system call and Protection
any return values. Process control
14. Three general methods are used to pass parameters to the operating i A running program needs to be able to halt its execution either
system. normally
i Pass parameters using registers but there may be more end ()
parameters than registers. abort ()
ii The parameters are stored in a block, or table, in memory, and ii A process or job executing one program may want to load() and
the address of the block is passed as a parameter in a register execute () another program.
(Figure 1.20) Linux and Solaris use this method. load ()
iii Parameters also can be placed or pushed, onto the stack by the execute ()
program and popped off the stack by the operating system. iii To create a new job or process and to terminate a created process
create process ()
25
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
26
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
Before communication can take place, a connection must be iii System calls manipulate the permission settings of resources such
opened. as files and disks.
The name of the other communicator must be known, be it another setpermission()
process on the same system or a process on another computer get permission()
connected by a communications network. iv Systemcalls specify whether particular users can or cannot be
A host name-Each computer in a network and has an IP allowed access to certain resources.
address allow user()
A process name -each process has a name and it is deny user()
translated into an identifier usingthe system calls get 1.11System Programs
hostid() and get processid() System programs, also known as system utilities,provide a convenient
ii To create, delete communication connection, send , receive environment for program development and execution. They are simply
messages, transfer status information and attach or detach remote user interfaces to system calls.
devices the following system calls are used, Categories:
open connection () 1. File management
close connection () 2. Status information.
accept connection () 3. File modification
read message() 4. Programming-language support
write message() 5. Program loading and execution.
wait for connection() 6. Communications.
2. The shared-memory model 7. Background services.
Processes use shared memory create() and shared memory attach() 1. File management
system calls to create and gain access to regions of memory owned by Manipulate files and directories.
other processes. These programs create, delete, copy, rename, print, dump and list
Protection files and directories.
i Protection provides a mechanism for controlling access to the 2. Status information
resourcesprovided by a computer system.
Programs that ask the system for the date, time, amount of
ii Protection was a concern only on multiprogrammed computer available memory or disk space, number of users, or similar status
systems with several users.
information.
27
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
28
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
29
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
30
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
31
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
8. Do timesharing differ from Multiprogramming? If so, How? 12. Consider a memory system with a cache access time of 10ns and a
Multiprogramming Time sharing systems memory access time of 110ns. If the effective access timeis 10% greater
Multiprogramming increases CPU Time sharing (or multitasking) is a than the cache access time, what is the hit ratio H? (Fractional answers
utilization and throughput by logical extension of are okay).
organizing jobs so that the CPU multiprogramming. It allows many Effect Access Time: Te= H x Tc+ (1 - H)(Tm+ Tc),
always has one to execute. users to share the computer where Tc= 10ns, Te= 1/1 x Tc, and Tm= 110ns.
simultaneously Thus, (1.1) x (10) = H x 10 + (1 – H) (110 + 10)
It provides an environment where The CPU executes multiple jobs by 11 = 10H + 120– 120H
the various system resources were switching among them, but the 110H = 120-11
utilized effectively, but it did not switches occur so frequently that the H= 109/110
provide for user interaction with the users can interact with each program H=0.99
computer system. while it is running. 13. What is the purpose of the command interpreter? Why is it usually
separate from the kernel?
9. How does an interrupt differ from a trap? It reads commands from the user or from a file of commands and
Interrupt Trap executes them, usually by turning them into one or more system calls. It
Interrupts are hardware errors A trap is asoftware generated is usually not part of the kernel since the command interpreter is subject
interrupt. to changes.
An interrupt can be used to signal Trap can be used to call operating 14. What are the three major activities of an operating system with
the completion of an I/O to obviate system routines or catch arithmetic regard to secondary-storage management?
the need of device polling. errors. The three major activities are:
• Free-space management.
10. What is the purpose of system calls? • Storage allocation.
System calls allow user-level processes to request services of the operating
• Disk scheduling.
system.
15. State the different modes of operation of operating systems.
11. Can traps be generated intentionally by a user program? If so, for what There two separate modes of operation:
purpose?
User mode-mode bit 1-execution on behalf of user
A trap is a software-generated interrupt.A trap can be generated
Kernel mode –mode bit 0-execution on behalf of OS
intentionally by a user program. It can be used to call operating system
16. Mention the purpose of the dual mode operation.
routines or to catch arithmetic errors.
The dual mode of operation provides us with the means for protecting the
operating system from errant users and errant users from one another.
32
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE
UNIT I – INTRODUCTION
Need 19. What are the three main purposes of an operating system?
Handling interrupts The three main purposes are:
To switch from user mode to kernel mode To provide an environment for a computer user to execute programs on
Input Output Management computer hardware in a convenient and efficient manner.
17. What are the three major activities of an operating system with To allocate the separate resources of the computer as needed to solve the
regard to memory management? problem given. The allocation process should be as fair and efficient as
The three major activities are: possible.
a. Keep track of which parts of memory are currently being used and by As a control program it serves two major functions:
whom. (1) Supervision of the execution of user programs to prevent errors and
b. Decide which processes are to be loaded into memory when memory improper use of the computer.
space becomes available. (2) Management of the operation and control of I/O devices.
c. Allocate and deallocate memory space as needed.
18. Some computer systems do not provide a privileged mode of
operation in hardware. Is it possible to construct a secure operating
system for these computer systems?
An operating system for a machine of this type would need to remain in
control (or monitor mode) at all times. This could be accomplished by two
methods:
(a) Software interpretation of all user programs (like some BASIC, Java,
and LISP systems, for example). The software interpreter would provide, in
software, what the hardware does not provide.
(b) Require that all programs be written in high-level languages so that all
object code is compiler-produced. The compiler would generate (either in-
line or by function calls) the protection checks that the hardware is missing.
33
AAMEC-Computer Science and Engineering CS3451-Introduction to Operating Systems Mrs.G.Kalaiselvi AP/CSE