Tutorial Point Study

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

Saturday, 16 February 2019

PCB (Process Control Block)

No comments
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

No comments
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:

No comments
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

No comments

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.

No comments
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

No comments
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

No comments
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

No comments
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)

No comments
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.

No comments
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.

No comments
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

Multiprocessor systems or Parallel Systems (also called tightly coupled systems)

No comments
Multiprocessor Operating System refers to the use of two or more central processing
units (CPU) within a single computer system. These multiple CPUs are in a close
communication sharing the computer bus, memory and other peripheral devices.
Multiprocessor systems are also called as parallel systems or tightly coupled systems.
These types of systems are used when very high speed is required to process a large
volume of data. These systems are generally used in environment like satellite control,
weather forecasting etc.
Advantages:
Increased Throughput: By increasing the number of processors, we expect to get more
work done in less time.
Economy of scale: Multiprocessor systems can cost less than equivalent multiple single-
processor systems, because they can share peripherals, mass storage, and power
supplies.
Increased reliability: As there are multiple processors in the system, failure of one
processor will not halt the system, only slow it down. This ability to continue providing
services proportional to the level of surviving hardware is called as graceful
degradation.
Disadvantages:
Multiprocessing can cause a system to change its memory access model from uniform
memory access (UMA) to non-uniform memory access (NUMA). NUMA is a kind of
situation in which some parts of memory may take longer to access than other parts
creating a performance penalty.
Types of multiprocessor systems:
There are two types: multiprocessor systems using asymmetric multiprocessing (ASMP)
and multiprocessor systems using symmetric multiprocessing (SMP).

In ASMP each processor is assigned a specific task. There is one master processor which
controls the system and the other processors are the slave processors. The master
processor allocates and schedules the work to the slave processors. Slave processors
perform the task given to them by master processor.
In SMP no master-slave relationship exists between processors. Each processor has its
own set of registers as well as local cache. All the processors share the same physical
memory and all of them run an identical copy of operating system

Real-Time OS or Real-Time Embedded System

No comments
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

No comments
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

Multiprogrammed Batch OS or Multiprogrammed Systems:

No comments
A single user cannot, in general, keep either the CPU or the I/O devices busy at all
times. Multiprogramming increases CPU utilization by organizing jobs such that the
CPU always has one to execute.
An OS does the following activities related to multiprogramming.
 The operating system keeps several jobs in memory at a time.
 This set of jobs is a subset of the jobs kept in the job pool.
 The operating system picks and begins to execute one of the jobs in the memory.
 When the executing job J1 needs to wait (for I/O or event completion), the
operating system simply switches to and start executing another job say J2. When
job J2 needs to wait, the CPU is switched to another job say J3, and so on.
 Once the first job J1 finished its I/O or event wait, it joins the ready queue and
waits for a CPU.
 Eventually, the first job J1 finishes waiting and gets the CPU back.
 As long as there is always some job ready to execute, the CPU will never be idle.
Advantages: High CPU Utilization.
Disadvantages: CPU Scheduling, Main Memory Management is required.

Batch Operating System

No comments
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.

Different types of Operating System.

No comments

Define operating system

No comments
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.