OS-Module 1-Notes
OS-Module 1-Notes
OS-Module 1-Notes
UNIT 1/MODULE 1
Chapter 1: Introduction to Operating System
Contents:
Operating-System Structure
Operating-System Operations
Operating system is software that controls and manages the computer hardware.
User Computations
Utilization Efficiency
User Convenience
Hardware
Operating system
Application programs
define the ways in which the system resources are used to solve the
computing problems of the users
Users
----------------------------------------------------------------------------------------------------------------
---------------------
User view
System view
Resource allocator
Control program
System View
OS is a resource allocator
Decides between conflicting requests for efficient and fair resource use
OS is a control program
“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 operation
Storage Structure
I/O Structure
Single user cannot keep CPU and I/O devices busy at all times
Multiprogramming organizes jobs (code and data) so CPU always has one to execute
When it has to wait (for I/O for example), OS switches to another job and so on
I/O routine is supplied by system to many programs.
CPU scheduling: the system must choose one job among several jobs ready to run.
The CPU executes several jobs that are kept in memory by switching among them.
CPU switching is so fast that the user can interact with each program while it is
running.
If processes don’t fit in memory, swapping moves them in and out from the memory
à memory management
OS is interrupt driven
Other process problems include infinite loop, processes modifying each other
or the operating system
As OS and users share hardware and software, they should not interfere in each other
operations.
User mode
A bit, mode bit, is added to computer hardware to indicate the current mode
Kernel (0)
User (1)
When a user process requests a service from OS via a system call, it transit from user
mode to kernel mode to fulfill the request
At boot time, hardware starts in kernel mode, then OS is loaded (mode bit = 0)
Whenever a trap or interrupt occurs, hardware switches from user to kernel mode
(mode bit = 0)
When a user process requests a service from OS via a system call, it transit from user
mode to kernel mode to fulfill the request
Provides the means for protecting the OS from erroneous programs and
erroneous programs from each other.
If any attempt is made to execute privileged instructions in user mode, hardware does
not execute these instructions and treats as traps
MS-DOS written for Intel 8088 architecture which has no mode bit and
therefore no dual mode.
Pentium provides dual mode; and Windows, Linux, Solaris make use of the feature
and provide protection to OS
1.3.2 Timer
A user program should not stuck in infinite loop i.e. not returning to OS.
The period may be fixed (1/60 sec) or variable (from 1 milisecond to 1 second)
A variable timer is implemented by a clock and a counter
At 0, an interrupt occurs
Set up timer before scheduling process to regain control or terminate program that
exceeds allotted time
UNIT 1/MODULE 1
Chapter 2: System Structure
Contents:
System Calls
An operating system provides the environment within which programs are executed.
Services provided by OS
User Interface
Program execution
I/O operations
File-system manipulation
Communications
Error detection
Resource allocation
Accounting
a. User Interface
Batch Interface uses files for execution containing commands and directives
Graphics User Interface (GUI) is window and uses pointing device, keyboard, menus
etc.
c. I/O operations
a. A running program may require I/O which may involve a file to load in memory
or an I/O device like keyboard
b. Since user programs cannot execute I/O operations directly due to efficiency and
protection purpose, the operating system must provide means to perform I/O.
d. File-system manipulation
e. Communications
f. Error detection
a. Resource allocation
Allocating resources to multiple users or multiple jobs running at the same time
b. Accounting
To keep track of which users use how much and what kinds of computer resources
This record keeping may be used for account billing or for accumulating usage
statistics.
Usage statistics is a valuable tool for researcher to reconfigure the system to improve
computing services
Concurrent processes should not interfere with each other or with OS itself
Authentication
========================================================================
===
2.2 SYSTEM CALLS
These routines are written in a high-level language (C or C++), low level tasks may be in
assembly language
System call sequence to copy the contents of one file to another file
System calls are mostly accessed by programs via a high-level Application Program
Interface (API) rather than directly using system call.
The API specifies a set of functions that are available to an application programmer, including
the parameters that are passed with each function.
Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based
systems (including all versions of UNIX, Linux, and Mac OS X), and Java API for the Java
virtual machine (JVM)
A program having APIs can be compiled and run on any system that support the same API.
Actual system calls can be more detailed and it is difficult to work with them.
A run-time support system for most of the programming languages provides a system call
interface that serves as the link to system calls made available by OS.
A run-time support system provides a set of functions built into libraries included with the
compiler
A number is associated with each system call.
The system call interface invokes intended system call in OS kernel and returns status of the
system call with its return value.
The programmers need not know about the system call implementation and just need to obey
API
Most of the details of OS interface are hidden from programmer by API and managed by run-
time support library (set of functions built into libraries included with compiler)
More information like parameters is required than simply identity of desired system call
Three general methods are used to pass parameters between a running program and the
operating system.
Store the parameters in a block of memory, and the memory address is passed as a
parameter in a register as in Linux, Solaris
Push the parameters onto the stack by the program, and pop off the stack by operating
system.
2.3 TYPES OF SYSTEM CALLS
Process control
File management
Device management
Information maintenance
Communications
To halt the execution of a running program either normally (end) or abnormally (abort), OS
transfers the to command interpreter
For coordination of concurrent processes, system calls may be wait event, signal event
end, abort
load, execute
Create and delete a file (or directory), need a file name and few attributes
Determine the values of various file attributes like file name, file type, protection codes
open, close
A process needs several resources for execution like main memory, disk drives, files etc.
All resources may be considered as devices which can be requested and released. (same as
open and close a file)
Many system calls exist for the purpose of transferring the information between the user
program and OS
System calls to return information about the system such as number of current users, OS
version, amount of free memory or disk
System calls to return to get and set the information for files, processes, devices
2.3.6 Communications
Message passing
Shared memory
Connection to be established
Processes can exchange the information by reading and writing the data in shared
memory
Shared memory is faster and can be done in same computer but synchronization is the issue