operating systems

38
FUNDAMENTALS OF FUNDAMENTALS OF OPERATING SYSTEMS OPERATING SYSTEMS

Upload: swapnil-choubey

Post on 05-Jan-2016

5 views

Category:

Documents


0 download

DESCRIPTION

Introduction to operating systems

TRANSCRIPT

Page 1: Operating Systems

FUNDAMENTALS OF FUNDAMENTALS OF OPERATING SYSTEMSOPERATING SYSTEMS

Page 2: Operating Systems

Syllabus

OS Introduction.

Process & Process Management.

Interprocess Communication and Synchronization, Deadlocks.

Memory Management.

File Management.

Page 3: Operating Systems
Page 4: Operating Systems

What is OS?

Operating System is a software, which makes a computer to actually work.

An OS is a program which acts as an interface between computer system users and the computer hardware.

It is the software the enables all the programs we use.

The OS organizes and controls the hardware.

Examples: Windows, Linux, Unix and Mac OS, etc.

Page 5: Operating Systems

What OS does?

An operating system performs basic tasks such as,

controlling and allocating memory.

prioritizing system requests.

controlling input and output devices.

facilitating networking.

managing file systems.

Page 6: Operating Systems

Abstract View of Operating System

Page 7: Operating Systems

Booting, a process to start OS

Booting is the initial set of operations that a computer system performs after electrical power to the CPU is switched on or when the computer is reset.

It is a process or set of operations that loads and hence starts the operating system, starting from the point when user switches on the power button.

Page 8: Operating Systems

Booting process steps

1. The power button activates the power supply in the PC, sending power to the motherboard and other components. Then PC performs a power-on self-test (POST) which indicates if their is a h/w failure.

2. The PC displays information on the attached monitor showing details about the boot process.

3. The BIOS attempts to access the first sector of the hard drive known as the boot disk. The boot disk is typically the same hard disk that contains your operating system.

4. The BIOS confirms there's a bootstrap loader, or boot loader, in that first sector of the boot disk, and it loads that boot loader into memory (RAM). The boot loader is a small program designed to find and launch the PC's operating system.

5. Once the boot loader is in memory, the BIOS hands over its work to the boot loader, which in turn begins loading the operating system into memory. When the boot loader finishes its task, it turns control of the PC over to the operating system. Then, the OS is ready for user interaction

Page 9: Operating Systems

Bootstrap Process

Page 10: Operating Systems

OS Services An Operating System provides services to both

the users and to the programs. It provides programs, an environment to execute. It provides users, services to execute the

programs in a convenient manner.

Following are few common services provided by operating systems. Program execution I/O operations File System manipulation Communication Error Detection Resource Allocation Protection

Page 11: Operating Systems

OS Types

Single User, single task

Single user, multi task

Multi user, multi task

Page 12: Operating Systems

Batch Processing

In Batch processing same type of jobs batch together and execute at a time.

The OS was simple, its major task was to transfer control from one job to the next.

OS keeps a number a jobs in memory and executes them without any manual information. Jobs are processed in the order of submission i.e. first come first served fashion.

When job completes its execution, its memory is released and the output for the job gets copied into an output spool for later printing or processing.

Page 13: Operating Systems

Advantages1.Batch processing takes much of the work of the operator to the computer.2.Increased performance as a new job get started as soon as the previous job finished without any manual intervention.

Disadvantages1.Difficult to debug program.2.A job could enter an infinite loop. Due to lack of protection scheme, one batch job can affect pending jobs.

Page 14: Operating Systems

Multitasking/TimeSharing

Multitasking refers to term where multiple jobs are executed by the CPU simultaneously by switching between them. Switches occur so frequently that the users may interact with each program while it is running.

The user gives instructions to the operating system or to a program directly, and receives an immediate response.

These Operating Systems were developed to provide interactive use of a computer system at a reasonable cost.

A time-shared operating system uses concept of CPU scheduling and multiprogramming to provide each user with a small portion of a time-shared CPU.

Each user has at least one separate program in memory. Example: Multics, Unix

Page 15: Operating Systems

A program that is loaded into memory and is executing is commonly referred to as a process.

When a process executes, it typically executes for only a very short time before it either finishes or needs to perform I/O.

Since interactive I/O typically runs at people speeds, it may take a long time to completed. During this time a CPU can be utilized by another process.

Operating system allows the users to share the computer simultaneously. Since each action or command in a time-shared system tends to be short, only a little CPU time is needed for each user.

Page 16: Operating Systems

Multiprogramming

Multiprogramming is a technique to execute number of programs simultaneously by a single processor.

In Multiprogramming, number of processes reside in main memory at a time.

The OS picks and begins to executes one of the jobs in the main memory.

If any I/O wait happened in a process, then CPU switches from that job to another job.

Hence CPU in not idle at any time.

Page 17: Operating Systems

Advantages1.High and efficient CPU utilization.2.User feels that many programs are allotted CPU almost simultaneously.Disadvantages1.CPU scheduling is required.2.To accommodate many jobs in memory, memory management is required.

Page 18: Operating Systems

Real Time Operating System

Real time systems represents are usually dedicated, embedded systems.

In such systems, Operating Systems typically read from and react to sensor data.

The Operating system must guarantee response to events within fixed periods of time to ensure correct performance.

Page 19: Operating Systems

Distributed OS Distributed environment refers to multiple

independent CPUs or processors in a computer system. Operating system does the following activities related to distributed environment.

OS Distributes computation logics among several physical processors.

The processors do not share memory or a clock.

Instead, each processor has its own local memory.

OS manages the communications between the processors. They communicate with each other through various communication lines.

Page 20: Operating Systems
Page 21: Operating Systems

OS Views Programmer’s View

Logical View

Physical View

Development View

Page 22: Operating Systems

Components/Logical View of OS

Page 23: Operating Systems

Unix Operating System

Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs.

The UNIX operating system is capable of handling activities from multiple users at the same time. The UNIX operating system is a set of programs that act as a link between the computer and the user.

There are various Unix variants available in the market. Solaris Unix, AIX, HP Unix and BSD are few examples. Linux is also a flavour of Unix which is freely available.

Several people can use a UNIX computer at the same time; hence UNIX is called a multiuser system.

A user can also run multiple programs at the same time; hence

UNIX is called multitasking.

Page 24: Operating Systems

Unix Structure

Page 25: Operating Systems

Four Basics of UNIX

Kernel: The kernel is the heart of the operating system. It interacts with hardware and most of the tasks like memory management, task scheduling and file management.

Shell: The shell is the utility that processes your requests. When you type in a command at your terminal, the shell interprets the command and calls the program that you want. The shell uses standard syntax for all commands. C Shell, Bourne Shell and Korn Shell are most famous shells which are available with most of the Unix variants.

Commands and Utilities: There are various command and utilities which you would use in your day to day activities. cp, mv, cat and grep etc. are few examples of commands and utilities. There are over 250 standard commands plus numerous others provided through 3rd party software. All the commands come along with various optional options.

Files and Directories: All data in UNIX is organized into files. All files are organized into directories. These directories are organized into a tree-like structure called the file system.

Page 26: Operating Systems

Unix Architecture

Page 27: Operating Systems

The File Subsystem

The characteristics of unix file system are: A hierarchal structure. Consistent treatment of data. Ability to create and delete files. Dynamic growth of files. Peripheral devices are also treated as files.

The file system is organized as a tree. The root node is called “root” and is denoted by “/”. Every non leaf node in this structure is a directory and every leaf node is a ordinary file/special device file.

The name of the file is given by the path name.

Page 28: Operating Systems
Page 29: Operating Systems

The internal representation of the file is in the form of iNode. This inode contains the information about the file such as its layout on the disk, its owner, its access permissions and last accessed time.

This inode is short form for index node. Every file has one inode.  The inodes of all the files on the system are stored in inode table. When we create a new file a new entry in the inode table is created.

The kernel contain two data structures file table and user file descriptor table. The file table is global table at the kernel level but the user file descriptor table is for every process. When a process creates a file or opens a file the entry for that is made in both the tables.

The information about the current state of the file is maintained in the file table. For example if the file is being written the information about the current cursor position is kept in the file table. This file table also checks whether the accessing process has access to that file or not.

The user file descriptor table keeps a track of all the files opened by the processes and what are the relationships between these files.

Page 30: Operating Systems

Process Subsystem

KERNEL process is created as part of the booting .

KERNEL first loads the init process •

All other processes are created by init •

Each process is given an unique process id (PID) –PID of init is 1 –PID of kernel is 0 (zero) .

Each process is associated with its creator (parent) –identified by the Parent Process ID (PPID) •initprocess is mother of all processes

Page 31: Operating Systems

When parent process of any process dies, it will be linked to init process as its parent •

Each process runs with a specific priority (PRI).

New processes are created using either fork or exec command •

fork creates an independent process –Except kernel everything else is created using fork •

Exec creates a new process as a sub-process (thread) of the calling program –It shares the memory and other resources of the parent process

Page 32: Operating Systems

Process States

Page 33: Operating Systems

Buffer Cache When a process wants to access data from

a file, the kernel brings the data into main memory, alters it and then request to save in the file system

Example: copy cp one.c two.c

To increase the response time and throughput, the kernel minimizes the frequency of disk access by keeping a pool of internal data buffer called buffer cache.

Page 34: Operating Systems

Buffer Cache Buffer cache contains the data in recently

used disk blocks.

When reading data from disk, the kernel attempts to read from buffer cache.

If data is already in the buffer cache, the kernel does not need to read from disk.

If data is not in the buffer cache, the kernel reads the data from disk and cache it.

Page 35: Operating Systems

Buffer Headers35 A buffer consists of two parts

a memory array buffer header

disk block : buffer = 1 : 1

Figure 3.1 Buffer Header

device num

block numstatus

ptr to next buf on hash queue

ptr to previous buf on hash queue

ptr to next buf on free listptr to previous buf on free list

ptr to data area

Page 36: Operating Systems

Buffer Headers36

device num logical file system number

block num block number of the data on disk

status The buffer is currently locked. The buffer contains valid data. delayed-write The kernel is currently reading or writing the contents of

the disk. A process is currently waiting for the buffer to become

free. kernel identifies the buffer content by examing

device num and block num.

Page 37: Operating Systems

Structures of the buffer pool37

Buffer pool according to LRU The kernel maintains a free list of buffer

doubly linked list take a buffer from the head of the free list. When returning a buffer, attaches the buffer to the tail.

Page 38: Operating Systems

Thank You!!!