Tutorial Point Study

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

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.

Wednesday 13 February 2019

Process and a Thread.

A process is a program in execution. A program by itself is not a process. Program is a
passive entity whereas process is an active entity.
A thread is a lightweight process which is a basic unit of CPU utilization.
Differences between process and thread.
1. Threads share the address space of the process that created it; whereas each process
has its own address space (separate).

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.

Interactive OS

Interactivity refers to the ability of users to interact with a computer system. An
Operating system does the following activities related to interactivity:
 Provides the user an interface to interact with the system.
 Manages input devices to take inputs from the user. For example, keyboard.
 Manages output devices to show outputs to the user. For example, Monitor.
 The response time of the OS needs to be short, since the user submits the
request and waits for the result.

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.

Distributed OS or Distributed Systems (also called loosely coupled systems)

Distributed system is a collection of physically separate, possibly heterogeneous,
computer systems that are networked to provide the users with access to the various
resources that the system maintains. Access to a shared resource increases computation
speed, functionality, data availability, and reliability.
In contrast to the tightly coupled systems, the processors in Distributed Systems do not
share memory or a clock. Instead, each processor has its own local memory and clock.
The processors communicate with one another through various communication lines,
such as high-speed buses or telephone lines within Local Area Network (LAN) or
Metropolitan Area Network (MAN) or Wide Area Network (WAN). These systems are
usually referred to as loosely coupled systems, or distributed systems.
The processors in a distributed system may vary in size and function. They may include
small microprocessors, workstations, minicomputers, and large general-purpose
computer systems. These processors are referred to by a number of different names,
such as sites, nodes, computers, and so on.
Advantages:
• Resource sharing. A user at one site may be able to use the resources available at
another site. For example, a user at site A may be using a laser printer available only at
site B. Meanwhile, a user at B may access a file that resides at A.
• Computation speedup. If a particular computation can be partitioned into a number
of sub computations that can run concurrently, then a distributed system may allow us
to distribute the computation among the various sites — to run that computation
concurrently. In addition, if a particular site is currently overloaded with jobs, some of
them may be moved to other, lightly loaded, sites. This movement of jobs is called load
sharing.
• Reliability. If one site fails in a distributed system, the remaining sites can potentially
continue operating.
• Communication. When many sites are connected to one another by a communication
network, the processes at different sites have the opportunity to exchange information.
Users may initiate file transfers or communicate with one another via electronic mail. A
user can send mail to another user at the same site or at a different site.

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.

functions of operating system as a resource manager.

From the computer's point of view, the operating system is the program most
intimately involved with the hardware. In this context, we can view an operating
system as a resource allocator. A computer system has many resources that may be
required to solve a given problem: to name the few the resources can be CPU time,
memory space, file-storage space, I/0 devices, and so on. The operating system acts as
the manager of these resources hence is called as resource manager. Facing numerous
and possibly conflicting requests for resources, the operating system must decide how
to allocate them to specific programs and users so that it can operate the computer
system efficiently and fairly. Resource allocation is especially important where many
users access the same mainframe or minicomputer.
Note: Discuss Memory Management, Processor Management, Device
Management, File Management given in Click here