Tutorial Point Study

This Blog provide simple notes in simple language of computer science and engineering.

Showing posts with label operating system. Show all posts

Saturday, 16 February 2019

PCB (Process Control Block)

A Process Control Block is a data structure maintained by the Operating System
for every process. The PCB is identified by an integer process ID (PID). A PCB
keeps all the information needed to keep track of a process as listed below:
 Process State: The current state of the process i.e., whether it is ready, running,
waiting, or whatever.
 Process privileges: This is required to grant/deny access to system resources.
 Process ID: Unique identification for each of the process (PID) and also having
Parent Process ID i.e. PPID in the operating system.
 Pointer: A pointer to parent process
 CPU Registers: Values in different CPU registers while a process is running.
 Program Counter: points to next instruction of a process to be executed.
 CPU Scheduling Information: Process priority and other information required for
scheduling a process.
 Memory Management Information: This includes the information of page table,
memory limits, Segment table etc. depending on memory used by the operating
system.
 Accounting information: This includes the amount of CPU used for process
execution, time limits, execution ID etc.
 List of open files: contains those files handles which are opened for a process.
 I/O Status Information: This includes a list of I/O devices allocated to the
process.

system call

System call is
Programming interface to the services provided by the OS
Typically written in a high-level language (C or C++)
Mostly accessed by programs via a high-level Application Programming
Interface (API) rather than direct system call use
Three most common APIs are Win32 API for Windows, POSIX API for POSIX-
based systems (including virtually all versions of UNIX, Linux, and Mac OS X),
and Java API for the Java virtual machine (JVM).

Example of System Calls
System call sequence to copy the contents of one file to another file

Types of System Calls
Process control
o create process, terminate process
o end, abort
o load, execute
o get process attributes, set process attributes
o wait for time
o wait event, signal event
o allocate and free memory
o Locks for managing access to shared data between processes
File management
o create file, delete file
o open, close file
o read, write, reposition
o get and set file attributes
Device management
o request device, release device
o read, write, reposition
o get device attributes, set device attributes
o logically attach or detach devices
Information maintenance
o get time or date, set time or date
o get system data, set system data
o get and set process, file, or device attributes
Communications
o create, delete communication connection
o send, receive messages if message passing model to host name or
process name from client to server
o Shared-memory model create and gain access to memory regions
o transfer status information
o attach and detach remote devices
Protection
o Control access to resources
o Get and set permissions
o Allow and deny user access

Dispatcher:

It is a module whose responsibility is to give control of a CPU to a
process selected by short term scheduler for execution. It is invoked by short-term
scheduler. The time taken by dispatcher to switch from one process to another is
called as dispatch latency. To keep this switching overhead to minimum dispatcher
should be as fast as possible.
The function of a dispatcher involves the following:
 Switching context (saving the execution environment of current process and
loading the execution environment of different process)
 Switching to user mode
 Jumping to a proper location in the user program to restart the program

Thursday, 14 February 2019

Process Scheduling


The process scheduling is the activity of the process manager that handles the removal
of the running process from the CPU and the selection of another process on the basis of
a particular strategy. Process scheduling is an essential part of multiprogramming
operating systems. Such operating systems allow more than one process to be loaded
into the main memory at a time and the loaded process shares the CPU using time
multiplexing.
Operating System maintains following process scheduling queues
Job queue – set of all processes in the system.
Ready queue – set of all processes residing in main memory, ready and waiting to
execute.
Device queues – set of processes waiting for an I/O device. Each device has its
own device queue.
Processes migrate among the various queues before its completion.

Tuesday, 12 February 2019

Various functions of the operating system

Following are some of important functions of an operating System.
Booting: Booting is a process of starting the computer. It checks the computer and
makes it ready to work.
Memory Management: Operating System does the following activities for memory
management:
 Keeps tracks of primary memory, i.e., what part of it are in use by whom, what
parts are not in use?
 Allocates the memory when a process requests it to do so.
 Deallocates the memory when a process no longer needs it or has been
terminated.
Loading and Execution: A program needs to be loaded in the main memory before it
can be executed. Operating system provides the facility to load programs in memory
and then execute it.
Data security: The operating system protects the data stored on the computer from
illegal use, modification or deletion.
Process Management: In multiprogramming environment, the OS decides which
process gets the processor when and for how much time. This function is called
process scheduling. In addition OS also provides a mechanism for process
synchronization, process communication and deadlock handling.
Device Management: An Operating System manages device communication via
their respective drivers. It does the following activities for device management:
 Keeps tracks of all devices using I/O controller.
 Decides which process gets the device when and for how much time.
 Allocates the device in the most efficient way.
 Deallocates devices.

File Management: A file system is normally organized into directories for easy
navigation and usage. These directories may contain files and other directions.
Providing interface: 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:
 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.
 Command-line interface: it provides an interface to communicate with the
computer by typing commands.
Security - By means of password, encryption/decryption and similar other
techniques, it prevents unauthorized access to programs and data.
Control over system performance - Recording delays between request for a service
and response from the system.
Job Accounting - Keeping track of time and resources used by various jobs and
users.
Error detecting aids - Production of dumps, traces, error messages, and other
debugging and error detecting aids.
Coordination between other software and users - Coordination and assignment of
compilers, interpreters, assemblers and other software to the various users of the
computer systems.

Network OS

Network operating system is an operating system that provides features such as file
sharing across the network and that includes the communication scheme that allows different processes on different computers to exchange messages.
Example: Microsoft Windows Server 2003, Microsoft Windows Server 2008, UNIX,
Linux, Mac OS X, Novell NetWare, and BSD.

Monday, 11 February 2019

services provided by OS.

Following are a few common services provided by an operating system:

Program execution: The system must be able to load a program in memory into
memory and to run that program. The program must be able to end its execution
either normally or abnormally.

I/O operations: A running program may require I/O. OS must provide a means
to access I/O devices to perform I/O.
File System manipulation: Program needs to read a file or write a file. The
operating system gives the permission to the program for operation on file.
Operating System also provides an interface to the user to create/delete files and
directories.

Communication: OS provides two techniques; shared memory & message
passing to facilitate communication among processes which may be running on
the same computer or may be running on different computers which are
connected over a network.

Error Detection: The OS constantly checks for possible errors in the working of
software programs and hardware components. The OS takes an appropriate
action to ensure correct and consistent computing.

Resource Allocation: In case of multi-user or multi-tasking environment,
resources such as main memory, CPU cycles and files storage are to be allocated
to each user or job. The OS is a manager of all kinds of resources in the computer
system and it uses different schedulers for doing resource management.

Protection: The OS ensures that all access to system resources is controlled and
protected from invalid access attempts. The access to various resources is
granted only after user authentication.

Real-Time OS or Real-Time Embedded System

A system is said to be Real Time if it is required to complete its work & deliver
its services on time.
Real time systems are used in an environment where a large number of events
(generally external) must be accepted and processed in a short time.
Example – Flight Control System
 All tasks in that system must execute on time.
Types of Real Time OS
Hard Real Time System
 Failure to meet deadlines is fatal
 Example: Flight Control System, Industrial control systems
Soft Real Time System
 Late completion of jobs is undesirable but not fatal.
 System performance degrades as more & more jobs miss deadlines
 Example: Online Databases, Online Reservation System.

Time-sharing OS or Multitasking Systems

Time-sharing is a technique which enables many people, located at various terminals, to
use a particular computer system at the same time. Time-sharing or multitasking is a
logical extension of multiprogramming. Processor's time is shared among multiple
users simultaneously. The operating system uses CPU scheduling and
multiprogramming to provide each user with a small portion of a time. Multiple jobs
are executed by the CPU by switching between them, but the switches occur so
frequently that user can interact with each program while it is running.
Advantages of Timesharing operating systems are as follows:
 Provides quick response i.e. short response time.
 Avoids duplication of software
 Reduces CPU idle time

Batch Operating System

The users of a batch operating system do not interact with the computer directly. Each
user prepares his job on an off-line device like punch cards and submits it to the
computer operator. To speed up processing, jobs with similar needs are batched
together and run as a group. The programmers leave their programs with the operator
and the operator then sorts the programs with similar requirements into batches.
The problems with Batch Systems are as follows:
 Lack of interaction between the user and the job.
 CPU is often idle, because the speed of the mechanical I/O devices is slower than
the CPU.

Define operating system

Definition-1:
An operating system is a program that manages the computer hardware. It also  provides a basis for application programs and acts as an intermediary between the  computer user and the computer hardware. The purpose of an operating system is to  provide an environment in which a user can execute programs in a convenient and  efficient manner.

Definition-2:
A computer system has many resources that may be required to solve a problem. The  resources can be CPU time, main memory space, file-storage space, I/O devices, and so  on. The operating system acts as the manager of these resources. Operating System is  also called as a control program that manages the execution of user programs to prevent  errors and improper use of the computer.

Definition-3:
An operating system is a program that controls the execution of application programs  and acts as an interface between the user of the computer and the computer hardware.  An OS has three major objectives:  Execute user programs and make solving user problems easier   Make the computer system convenient to use   Use the computer hardware in an efficient manner

 Definition-4:
Operating System is the one program running at all times on the computer - usually  called the kernel. (Along with the kernel, there are two other types of programs: System Programs which are associated with the operating system but are not part of the  kernel, and application programs which include all programs not associated with the  operation of the system.) Definition-5: The operating system is the most fundamental piece of software and it runs in kernel  mode (also called supervisor mode). In this mode it has complete access to all the  hardware and can execute any instruction the machine is capable of executing. The rest  of the software runs in user mode, in which only a subset of the machine instructions is  available. In particular, those instructions that affect control of the machine or do I/O  (Input/output) are forbidden to user mode programs.