Module 1 Os
Module 1 Os
• If the user is using standalone system, then OS is designed for ease of use
and high performances. Here resource utilization is not given importance.
• If the users are in workstations, connected to networks and servers, then the
user have a system unit of their own and shares resources and files with other
systems. Here the OSis designed for both ease of use and resource availability
(files).
• Other systems like embedded systems used in home device (like washing m/c)
& automobiles do not have any user interaction. There are some LEDs to
show the status of its work
• Users of hand-held systems, expects the OS to be designed for ease of use and
performance per amount of battery life
System Views: - Operating system can be viewed as a resource allocator and control
program.
Multiprogramming
One of the most important aspects of operating systems is the ability to multiprogram. A
single user cannot keep either the CPU or the I/O devices busy at all times.
Multiprogramming increases CPU utilization by organizing jobs, so that the CPU
always has one to execute.
In Time sharing (or multitasking) systems, a single CPU executes multiple jobs
by switching among them, but the switches occur so frequently that the users can
interact with each program while it is running. The user feels that all the programs
are being executed at the same time.
Time sharing requires an interactive (or hands-on) computer system, which
provides direct communication between the user and the system. The user gives
instructions to the operating system or to a program directly, using a input device
such as a keyboard or a mouse, and waits for immediate results on an output device.
Accordingly, the response time should be short— typically less than one second.
A time-shared operating system allows many users to share the computer
simultaneously. As the system switches rapidly from one user to the next, each user
is given the impression that the entire computer system is dedicated to his use only,
even though it is being shared among many users.
A multiprocessor system is a computer system having two or more CPUs within
a single computer system, each sharing main memory and peripherals. Multiple
programs are executed by multiple processors parallel.
4)op services ?
Operating-System Services
• User Interfaces - Means by which users can issue commands to the system.
Depending on the operating system these may be a command-line interface ( e.g.
sh, csh, ksh, tcsh, etc.), a Graphical User Interface (e.g. Windows, X-Windows,
KDE, Gnome, etc.), or a batch command systems.
In Command Line Interface (CLI)- commands are given to the system.
In Batch interface – commands and directives to control these commands are put
in a file and then the file is executed.
In GUI systems- windows with pointing device to get inputs and keyboard to enter
the text.
• Program Execution - The OS must be able to load a program into RAM, run the
program, and terminate the program, either normally or abnormally.
• I/O Operations - The OS is responsible for transferring data to and from I/O
devices, including keyboards, terminals, printers, and files. For specific devices,
special functions are provided (device drivers) by OS.
• File-System Manipulation – Programs need to read and write files or directories.
The services required to create or delete files, search for a file, list the contents of
a file and change the file permissions are provided by OS.
• Communications - Inter-process communications, IPC, either between processes
running on the same processor, or between processes running on separate
processors or separate machines. May be implemented by using the service of OS-
like shared memory or message passing.
• Error Detection - Both hardware and software errors must be detected and
handled appropriately by the OS. Errors may occur in the CPU and memory
hardware (such as power failure and memory error), in I/O devices (such as a
parity error on tape, a connection failure on a network, or lack of paper in the
printer), and in the user program (such as an arithmetic overflow, an attempt to
access an illegal memory location).
• Resource Allocation – Resources like CPU cycles, main memory, storage space,
and I/O devices must be allocated to multiple users and multiple jobs at the same
time.
• Accounting – There are services in OS to keep track of system activity and
resource usage, either for billing purposes or for statistical record keeping that can
be used to optimize future performance.
• Protection and Security – The owners of information (file) in multiuser or
networked computer system may want to control the use of that information. When
several separate processes execute concurrently, one process should not interfere
with other or with OS. Protection involves ensuring that all access to system
resources is controlled. Security of the system from outsiders must also be done,
by means of a password.
5) Dual mode operation?
Explain dual mode operation in operating system with a neat block
diagramDual-Mode Operation
Since the operating system and the user programs share the hardware and software
resources of the computer system, it has to be made sure that an error in a user program
cannot cause problems to other programs and the Operating System running in the system.
The approach taken is to use a hardware support that allows us to differentiate among
various modes of execution.
A hardware bit of the computer, called the mode bit, is used to indicate the current
mode: kernel (0) or user (1). With the mode bit, we are able to distinguish between
a task that is executed by the operating system and one that is executed by the user.
When the computer system is executing a user application, the system is in user
mode. When a user application requests a service from the operating system (via a
system call), the transition from user to kernel mode takes place.
At system boot time, the hardware starts in kernel mode. The operating system is then
loaded and starts user applications in user mode. Whenever a trap or interrupt occurs, the
hardware switches from user mode to kernel mode (that is, changes the mode bit from 1
to 0). Thus, whenever the operating system gains control of the computer, it is in kernel
mode.
The dual mode of operation provides us with the means for protecting the operating
system from errant users—and errant users from one another.
Initial control is within the operating system, where instructions are executed in
kernel mode. When control is given to a user application, the mode is set to user
mode. Eventually, control is switched back to the operating system via an interrupt,
a trap, or a system call.
6)process states and process controller blocks?
Q)Illustrate with a neat sketch, the process states and process control block.
Process State
A Process has 5 states. Each process may be in one of the following states –
For each process there is a Process Control Block (PCB), which stores the process-
specific information as shown below –
• Process State – The state of the process may be new, ready, running, waiting, and
so on.
• Program counter – The counter indicates the address of the next instruction to be
executed for this process.
• CPU registers - The registers vary in number and type, depending on the computer
architecture. They include accumulators, index registers, stack pointers, and
general-purpose registers. Along with the program counter, this state information
must be saved when an interrupt occurs, to allow the process to be continued
correctly afterward.
• CPU scheduling information- This information includes a process priority,
pointers to scheduling queues, and any other scheduling parameters.
• Memory-management information – This includes information such as the value
of the base and limit registers, the page tables, or the segment tables.
• Accounting information – This information includes the amount of CPU and real
time used, time limits, account numbers, job or process numbers, and so on.
• I/O status information – This information includes the list of I/O devices
allocated to the process, a list of open files, and so on.
The PCB simply serves as the repository for any information that may vary from process
to process.
memory and file systems. The init process with a PID of 1, serves as a parent
process for all user processes.
A process will need certain resources (CPU time, memory, files, I/O devices) to
accomplish its task. When a process creates a subprocess, the subprocess may be
able to obtain its resources in two ways:
directly from the operating system
Subprocess may take the resources of the parent
process. The resource can be taken from parent in
two ways –
▪ The parent may have to partition its resources among its children
▪ Share the resources among several children.
There are two options for the parent process after creating the child:
• Wait for the child process to terminate and then continue execution. The parent
makes a wait() system call.
• Run concurrently with the child, continuing to execute without waiting.
Two possibilities for the address space of the child relative to the parent:
• The child may be an exact duplicate of the parent, sharing the same program
and data segments in memory. Each will have their own PCB, including
program counter, registers, and PID. This is the behaviour of the fork system
call in UNIX.
• The child process may have a new program loaded into its address space, with
all new code and data segments. This is the behaviour of the spawn system
calls in Windows.
In UNIX OS, a child process can be created by fork() system call. The fork
system call, if successful, returns the PID of the child process to its parents and
returns a zero to the child process. If failure, it returns -1 to the parent. Process
IDs of current process or its direct parent can be accessed using the getpid( ) and
getppid( ) system calls respectively.
The parent waits for the child process to complete with the wait() system call.
When the child process completes, the parent process resumes and completes its
execution.
In windows the child process is created using the function createprocess( ). The
createprocess( ) returns 1, if the child is created and returns 0, if the child is not created.
Process Termination
• A process terminates when it finishes executing its last statement and asks the
operating system to delete it, by using the exit () system call. All of the resources
assigned to the process like memory, open files, and I/O buffers, are deallocated
by the operating system.
• A process can cause the termination of another process by using appropriate system
call. The parent process can terminate its child processes by knowing of the PID
of the child.
• A parent may terminate the execution of children for a variety of reasons, such as:
The child has exceeded its usage of the resources, it has been allocated.
The task assigned to the child is no longer required.
The parent is exiting, and the operating system terminates all the children.
This is called cascading termination.
8) Multithreded programing ,definition ,models,benefits?
Assignment
1}with neat dia, explain the concept of virtual machine?
Q) Demonstrate the concept of virtual machine with an example
• The fundamental idea behind a virtual machine is to abstract the hardware of a
single computer (the CPU, memory, disk drives, network interface cards, and so
forth) into several different execution environments, thereby creating the illusion
that each separate execution environment is running its own private computer.
• Creates an illusion that a process has its own processor with its own memory.
• Host OS is the main OS installed in system and the other OS installed in the system
are called guest OS.
Implementation
• The virtual-machine concept is useful, it is difficult to implement.
• Work is required to provide an exact duplicate of the underlying machine.
Remember that the underlying machine has two modes: user mode and kernel
mode.
• The virtual-machine software can run in kernel mode, since it is the operating
system. The virtual machine itself can execute in only user mode.
Benefits
• Able to share the same hardware and run several different execution environments
(OS).
• Host system is protected from the virtual machines and the virtual machines are
protected from one another. A virus in guest OS, will corrupt that OS but will not
affect the other guest systems and host systems.
• Even though the virtual machines are separated from one another, software
resources can be shared among them. Two ways of sharing s/w resource for
communication are:
o To share a file system volume (part of memory).
o To develop a virtual communication network to communicate between the
virtual machines.
• The operating system runs on and controls the entire machine. Therefore, the
current system must be stopped and taken out of use while changes are made and
tested. This period is commonly called system development time. In virtual
machines such problem is eliminated. User programs are executed in one virtual
machine and system development is done in another environment.
• Multiple OS can be running on the developer’s system concurrently. This helps
in rapid porting and testing of programmer’s code in different environments.
System consolidation – two or more systems are made to run in a single system
Examples
VMware
The Java Virtual Machine
System Boot
Operating System Generation
2)what is system calls explain the different types of system call?
• System calls provides an interface to the services of the operating system. These
are generally written in C or C++, although some are written in assembly for
optimal performance.
• The below figure illustrates the sequence of system calls required to copy a file
content from one file (input file) to another file (output file).
1. Process Control
2. File management
3. Device management
4. Information management
5. Communications
6. Protection
Figure: Types of system calls
1. Process Control
• Process control system calls include end, abort, load, execute, create process,
terminate process, get/set process attributes, wait for time or event, signal event,
and allocate and free memory.
• Processes must be created, launched, monitored, paused, resumed, and eventually
stopped.
• When one process pauses or stops, then another must be launched or resumed
• Process attributes like process priority, max. allowable execution time etc. are
set and retrieved by OS.
• After creating the new process, the parent process may have to wait (wait time),
or wait for an event to occur (wait event). The process sends back a signal when
the event has occurred (signal event)
•
2. File Management
• The file attributes like filename, file type, permissions, etc. are set and
retrieved using system calls.
• These operations may also be supported for directories as well as ordinary files.
3. Device Management
4. Information Maintenance
• Information maintenance system calls include calls to get/set the time, date,
system data, and process, file, or device attributes.
• These system calls care used to transfer the information between user and the
OS. Information like current time & date, no. of current users, version no. of
OS, amount of free memory, disk space etc. are passed from OS to the user.
5. Communication
• Communication system calls
create/delete communication connection,
send/receive messages, transfer status information, and
attach/detach remote devices.
• The message passing model must support calls to:
o Identify a remote process and/or host with which to
communicate.
o Establish a connection between the two processes.
o Open and close the connection as needed.
6. Protection
• Protection provides mechanisms for controlling which users /
processes have access to which system resources.
• System calls allow the access mechanisms to be adjusted as needed,
and for non- privileged users to be granted elevated access
permissions under carefully controlled temporary circumstances.