UNIT-1 Os-1
UNIT-1 Os-1
Operating System
An Operating system is a collection of software that manages computer hardware resources and Provides
common services for computer programs. The operating system is a vital component of the system
software in a computer system.
An operating System is an intermediary between users and computer hardware. It provides users an
environment in which a user can execute programs conveniently and efficiently.
An operating System controls the allocation of resources and services such as memory,
processors, devices and information.
Operating system is a control program which controls the execution of user programs and
operations of I/O devices.
2) Operating system – controls and coordinates the use of the hardware among the various application
programs for the various users.
2) The interface that the operating system makes available to users and programmers.
System Components
A process is a program in execution. A process needs certain resources, including CPU time, memory,
files, and I/O devices, to accomplish its task.
The operating system is responsible for the following activities in connection with process management.
Main-Memory Management
Memory is a large array of words or bytes, each with its own address. It is a repository of quickly
accessible data shared by the CPU and I/O devices.
Main memory is a volatile storage device. It loses its contents in the case of system failure.
The operating system is responsible for the following activities in connections with memory management
Keeping track of which parts of memory are currently being used and by whom
Deciding which processes to be loaded into memory when memory space becomes available.
Allocating and de-allocating memory space as needed.
File Management
A file is a collection of related information defined by its creator. Commonly, files represent programs
and data. The operating system is responsible for the following activities in connections with file
management:
A buffer-caching system
A general device-driver interface
Drivers for specific hardware devices
Secondary-Storage Management
Since main memory (primary storage) is volatile and too small to accommodate all data and programs
permanently, the computer system must provide secondary storage to back up main memory.
Most modern computer systems use disks as the principle on-line storage medium, for both programs and
data
A distributed system is a collection processor that do not share memory or a clock. Each processor has its
own local memory. The processors in the system are connected through a communication network.
Communication takes place using a protocol. A distributed system provides user access to various
systems resources. Access to a shared resource allows:
Computation speed-up
Enhanced reliability
Protection System
Protection refers to a mechanism for controlling access by programs, processes, or users to both system
and user resources. The protection mechanism must:
Command-Interpreter System
Many commands are given to the operating system by control statements which deal with:
I/O handling
Secondary-storage management
Main-memory management
File-system access
Protection
Networking
An Operating System provides services to both the users and to the programs. It provides programs, an
environment to execute. It provides users, services to execute the programs in a convenient manner.
Program execution
I/O operations
File System manipulation
Communication
Error Detection
Resource Allocation
Protection
Program execution
Operating system handles many kinds of activities from user programs to system programs like printer
spooler, name servers, file server etc. Each of these activities is encapsulated as a process.
A process includes the complete execution context (code to execute, data to manipulate, registers, OS
resources in use). Following are the major activities of an operating system with respect to program
management.
Loads a program into memory.
Executes the program.
Handles program's execution.
Provides a mechanism for process synchronization.
Provides a mechanism for process communication.
Provides a mechanism for deadlock handling.
I/O Operation
I/O subsystem comprised of I/O devices and their corresponding driver software. Drivers hides the
peculiarities of specific hardware devices from the user as the device driver knows the peculiarities of the
specific device.
Operating System manages the communication between user and device drivers. Following are the major
activities of an operating system with respect to I/O Operation.
I/O operation means read or write operation with any file or any specific I/O device.
Program may require any I/O device while running.
Operating system provides the access to the required I/O device when required.
Keep track of and record which users use how much and what kinds of computer resources for
accounting or for accumulating usage statistics.
System Calls
System calls provide the interface between a running program and the operating system. Certain systems
allow system calls to be made directly form a high-level programming language such as C, C++ program
in which these calls normally resemble predefined function or sub-routine calls.
Process control
o end, abort
o load, execute
o create process, terminate process
Communication Models
Communication may take place using either message passing or shared memory
System Programs
o File management
o Status information
o File modification
o Programming language support
o Program loading and execution
o Communications
o Application programs
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. That information is then formatted,
and is printed to the terminal or other output device or file.
File modification: Several text editors may be available to create and modify the content of files stored on
disk or tape.
Program loading and execution: Once a program is assembled or compiled, it must be loaded in to
memory. To be executed the system may provide absolute loaders, re-locatable loaders, linkage editors,
and overlay loaders. Debugging systems for either higher-level languages or machine language are
needed also.
Communications: These programs provide the mechanism for creating virtual connections among
processes, users and different computer systems. They allow users to send messages to one another’s
screens, to browse web pages, to send electronic-mail messages, to log in remotely, or to transfer files
from one machine to another.
Most users’ view of the operation system is defined by system programs, not the actual system calls.
System Structure
A system as large and complex as a modern operating system must be engineered carefully if it is to
function properly and be modified easily. A common approach is to partition the task into small
components, rather than have one monolithic system. Each of these modules should be a well-defined
partition of the system, with carefully defined inputs, outputs and function.
1) Simple Structure
UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring.
Systems programs
The kernel - Consists of everything below the system-call interface and above the physical
hardware. Provides the file system, CPU scheduling, memory management, and other operating-
system functions; a large number of functions for one level
The operating system is divided into a number of layers (levels), each built on top of lower layers. The
bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface.
With modularity, layers are selected such that each uses functions (operations) and services of only
lower-level layer
Moves as much from the kernel into “user” space. Communication takes place between user modules
using message passing.
Benefits:
o More secure
Drawbacks:
QNX is a real-time operating system that is also based upon the microkernel design. The QNX
microkernel provides services for message passing and process scheduling. It also handles low-level
network communication and hardware interrupts. All other services in QNX are provided by standard.
Processes that run outside the kernel in user mode.
A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the
operating system kernel as though they were all hardware.
The operating system creates the illusion of multiple processes, each executing on its own processor with
its own (virtual) memory
The resources of the physical computer are shared to create the virtual machines
o CPU scheduling can create the appearance that users have their own processor
o Spooling and a file system can provide virtual card readers and virtual line printers
o A normal user time-sharing terminal serves as the virtual machine operator’s console
System Models
The virtual-machine concept provides complete protection of system resources since each virtual
machine is isolated from all other virtual machines. This isolation, however, permits no direct
sharing of resources.
A virtual-machine system is a perfect vehicle for operating-systems research and development.
System development is done on the virtual machine, instead of on a physical machine and so does
not disrupt normal system operation.
The virtual machine concept is difficult to implement due to the effort required to provide an
exact duplicate to the underlying machine
Compiled Java programs are platform-neutral byte codes executed by a Java Virtual Machine (JVM)
JVM consists of
Class loader
o Class verifier
o Runtime interpreter
User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast
System goals – operating system should be easy to design, implement, and maintain, as well as flexible,
reliable, error-free, and efficient
The separation of policy from mechanism is a very important principle, it allows maximum flexibility if
policy decisions are to be changed later
System Implementation
Traditionally written in assembly language, operating systems can now be written in higher-level
languages
o Is more compact.
An operating system is far easier to port (move to some other hardware) if it is written in a high-level
language.
Process Concept
An operating system executes a variety of programs:
o Batch system – jobs
o stack
Process State
As a process executes, it changes state
o new: The process is being created
Schedulers
Long-term scheduler (or job scheduler) – selects which processes should be brought into
the ready queue
Short-term scheduler (or CPU scheduler) – selects which process should be executed next
and allocates CPU
Addition of Medium Term Scheduling
Execution
o Parent and children execute concurrently
Address space
o Child duplicate of parent
UNIX examples
o fork system call creates new process
o exec system call used after a fork to replace the process’ memory space with a
new program
Processes Tree on a UNIX System
Process Termination
Process executes last statement and asks the operating system to decide it (exit)
Process executes last statement and asks the operating system to decide it (exit)
Cooperating Processes
Independent process cannot affect or be affected by the execution of another
process
Cooperating process can affect or be affected by the execution of another process
Advantages of process cooperation
Information sharing
Direct Communication
Processes must name each other explicitly:
o send (P, message) – send a message to process P
Indirect Communication
Messages are directed and received from mailboxes (also referred to as ports)
o Each mailbox has a unique id
Operations
o create a new mailbox
o destroy a mailbox