Vous êtes sur la page 1sur 76

Operating System

Presented by Vinod Gandhi

A program that manage computer hardware. OR we can say that Operating system is an intermediary between the user and computer hardware.

Computer-System Architecture
Operating systems have been evolving through the years. since operating systems historically have been closely tied to the architecture of the computers on which they run.

Presented by Vinod Gandhi

Computer-Systemsystems Architecture Continue Simple batch


Deck of cards. Spooling Batch Systems OR Multiprogramming batch systems. Magnetic tap instead of deck of cards. Single processor systems Multiprocessor Systems Cluster Systems Group of linked computer connected to each other. GPU(Graphical process unit). Disk-controller microprocessor Keyboard microprocessor

Presented by Vinod Gandhi

Components of the operating system


kernel
management of memory, processes, files, main inputs/outputs and communication functionalities.

Shell
A peace of software provide interface for user.

file system
allowing files to be recorded in a tree structure.

Presented by Vinod Gandhi

Presented by Vinod Gandhi

OS operations
Process management
y A process is a program in execution. give a work to computer to process it) It is a

unit of work within the system.


y Process needs resources to accomplish Done its task for task it need) CPU,

Memory, files, I/O devices


y Process termination requires reclaim of any reusable resources now you can use

this memory cause it s free)

Presented by Vinod Gandhi

OS operations continue
Memory Management(OS)
y y y

All data in memory before and after processing All instructions in memory in order to execute Memory management determines what is in memory when optimizing CPU utilization and computer response to users

Presented by Vinod Gandhi

OS operations continue
Storage Management
y y

OS provides uniform, logical view of information storage Each medium is controlled by device (i.e., disk drive, tape drive)

Presented by Vinod Gandhi

OS operations continue
File-System management
y y

Files usually organized into directories Access control on most systems to determine who can access what(secutiry in operating system) Creating and deleting files and directories Mapping files onto secondary storage Backup files onto stable (non-volatile) storage media

y y y

Presented by Vinod Gandhi

10

What is OS process?
A process is just an executing In running condition . Program, including the current values of the program counter, registers, and variables. In other word giving a task to the CPU is called processing.. Q:then we can say that material on the hard disk is being process? Ans:: the material in hard disk is not a process...

Presented by Vinod Gandhi

11

An operating system executes a variety of programs:


Batch system
Given All jobs together to CPU for processing.

Time-shared systems
It will share the job in period of time.

Presented by Vinod Gandhi

12

A process includes:
Program counter
Are the CPU free or not...

Stack
how many processes the CPU have now

Data section
What type information the CPU has...

Presented by Vinod Gandhi

13

As a process executes, it is being created. New: The process changes state


Running: Instructions are being executed. Waiting: The process is waiting for some event to occur. Ready: The process is waiting to be assigned to a process. Terminated: The process has finished execution.

Presented by Vinod Gandhi

14

Process Control Block (PCB )


 It contains information about the process  Tell us about the status of the process  Every process have their own PCB.

Process state Program counter CPU registers Input output status CPU scheduling information Memory-management information Accounting information

Presented by Vinod Gandhi

15

Types of Process Scheduling


y y y
set of all processes in the system. When process job not load in memory... set of all processes residing in main memory, ready and waiting to execute.

Job queue

Ready queue

Device queues

set of processes waiting for an I/O device.

Presented by Vinod Gandhi

16

Schedulers
selects which processes should be brought into the ready queue. Long-term scheduler is invoked very infrequently (seconds, minutes) (may be slow).

Long-term scheduler (or job scheduler)

Short-term scheduler

(or CPU scheduler) selects which process should be executed next and allocates CPU. Short-term scheduler is invoked very frequently (milliseconds) (must be fast).

The key idea behind a medium term scheduler is that Sometimes it can be advantageous to remove processes from memory to reduce the degree of multiprogramming. After some time the process can be introduced into memory and its execution can be continued where it left off. This scheme is called swapping...

medium term scheduling:-

Presented by Vinod Gandhi

17

Process operations
the processes in the system can execute concurrently and must be created and deleted dynamically. Thus, the operating system must provide a mechanism for process creation and termination.

Presented by Vinod Gandhi

18

Process operations continue


1. 2. 3.

Process Creation: Process termination Cooperating processes

Presented by Vinod Gandhi

19

CPU SCEDULING
THE QUESTION DOES ARRIES??????? We have a single physical CPU and a lot of processes/jobs to run Which process do we run next? For how long do we run it?

Presented by Vinod Gandhi

20

Basic Concepts
y Maximum CPU utilization obtained with multiprogramming y CPU I/O Burst Cycle

Process execution consists of a cycle of CPU execution and I/O wait.

y CPU burst distribution Burst time is an assumption of how long a

process requires the cpu between I/O waits. It can not be predicted exactly, before a process starts.

Presented by Vinod Gandhi

21

CPU Scheduler
When ever the cpu become idle, the operating system must select one of the processes in the ready queue not the FIFO) to be executed. the selection process is carried out by the Short-term scheduler .the scheduler selects from among the processes in memory that are ready to execute, and allocated the cpu to one of them.

Presented by Vinod Gandhi

22

Preemptive & non-preemptive scheduling


y Non preemptive
once CPU given to the process it cannot be preempted until completes its CPU burst. y Terminates. y Switches from running to waiting state.

y Preemptive

if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF). y Switches from running to ready state. y Switches from waiting to ready.

Presented by Vinod Gandhi

23

Dispatcher
Another component involved in the CPU scheduling function is the dispatcher is the module that gives control of the CPU to the process selected by the short-term scheduler; this involves:
1. 2. 3.

switching context switching to user mode jumping to the proper location in the user program to restart that program Dispatch latency time it takes for the dispatcher to stop one process and start another running.

Presented by Vinod Gandhi

24

Scheduling Criteria CPU utilization


keep the CPU as busy as possible

Throughput
processes that complete their execution per time unit

Turnaround time
the interval from the time of submission of a process to the time of completion is the turnaround time. Turnaround time is the sum of the periods spent waiting to get into memory, waiting in the ready queue, executing on the CPU,and doing i/o.

Waiting time
amount of time a process has been waiting in the ready queue

Response time
amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)

Presented by Vinod Gandhi

25

Scheduling Algorithms
CPU scheduling deals with which of the processes in allocated the CPU. There scheduling algorithms. Here one the problems of deciding the ready queue is to be are many different CPU we will describe it one by

Presented by Vinod Gandhi

26

Process Burst Time First-Come, First-Served 24 (FCFS) Scheduling P1 P2 3 P3 3 Suppose that the processes arrive in the order: P1 , P2 , P3 Waiting time for P1 = 0; P2 = 24; P3 = 27 Advantage Its is fair scheduling Disadvantage short jobs have to wait for longer jobs

Presented by Vinod Gandhi

27

Shortest-Job-First (SJR)
Process Burst Time P1 24 P2 3 P3 7 the processes will be arrive in the order: P2 , P3 , P1 Waiting time for P2 = 0; P3 = 3; P3 = 10
If two process have the same length next CPU burst,FCFS scheduling is used to break the tie.

Presented by Vinod Gandhi

28

Round Robin (RR) Scheduling


Each process gets a small unit of CPU time (time quantum or time slice), is defined first. usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. Example of RR with Time Quantum = 8 Burst Time Process P1 8 P2 16 P3 23 P4 7 Disadvantage: The most time will be spend in context switching.

Presented by Vinod Gandhi

29

Multilevel queuealgorithms allow different algorithms to be used algorithms Multilevel queue


for various classes of processes. The most common is a foreground interactive queue, which uses RR scheduling and a background batch queue, which uses FCFS scheduling. Multilevel feedback queues allow processes to move from one queue to another.

Presented by Vinod Gandhi

30

Memory management
y One of the most important tasks that an operating system does is manage the memory requirements of your computer.

Presented by Vinod Gandhi

31

Why need memory management?


Imagine if you had ten people sitting and working around your desk, and each of those people put their paperwork all over the desk. The desk would soon become unmanageable, with the paperwork hard to find or even lost. Eventually all ten people would probably not be able to complete their tasks. Somebody needs to take control and organize the chaos so on a computer this management (memory management) one of the jobs of the operating system.

Concept:
Main memory is usually too small to accommodate all the data and programs permanently, the computer system must provide secondary storage to back up main memory.

Presented by Vinod Gandhi

32

What is swapping?
y Swapping is just another word for trading (barter) or switching. y Replacing one segment of a program in memory with another and

restoring it back to the original when required.


y A process can be swapped temporarily out of memory to a backing store, and then

brought back into memory for continued execution.

Presented by Vinod Gandhi

33

Memory Allocation
y Multiple-partition allocation

Hole

block of available memory


OS process 5 OS process 5 OS process 5 process 9 process 8 process 2 process 2 OS process 5 process 9 process 10 process 2

process 2

Presented by Vinod Gandhi

34

Dynamic Storage-Allocation Problem


y First-fit: Allocate the first hole that is big enough y Next-fit: look for first-fit from last allocation y Best-fit: Allocate the smallest hole that is big enough; must search entire list,

unless ordered by size. Produces the smallest leftover hole.


y Worst-fit: Allocate the largest hole; must also search entire list. Produces the

largest leftover hole.

Presented by Vinod Gandhi

35

Dynamic Storage-Allocation Problem

Presented by Vinod Gandhi

36

Fragmentation
y Refers to the condition of a disk in which files are divided into pieces

scattered around the disk. Fragmentation occurs naturally when you use a disk frequently, creating, deleting, and modifying files. At some point, the operating system needs to store parts of a file in noncontiguous clusters. This is entirely invisible to users, but it can slow down the speed at which data is accessed because the disk drive must search through different parts of the disk to put together a single file

Presented by Vinod Gandhi

37

Fragmentation
y External Fragmentation
free memory space is broken non-contiguous pieces, none big enough to satisfy a request

y Internal Fragmentation
allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.

y Reduce external fragmentation by compaction


Shuffle memory contents to place all free memory together in one large block., this can be expensive y Compaction is possible only if relocation is dynamic, and is done at execution time. y Or, use Paging
y
Presented by Vinod Gandhi 38

Paging

Divide logical memory into blocks of same size called pages.

Presented by Vinod Gandhi

39

Paging example
y y

Page size = 4 bytes Physical memory = 32 bytes (8 pages)

Presented by Vinod Gandhi

40

THE QUESTION DOES ARRIES??????? Purpose of File system?


ONE OF SEVERAL REASONZ.
it must be possible to store a very large amount of information. The information must survive the termination of the process using it (database). Multiple processes must be able to access the information concurrently. The usual solution to all these problems is to store information on disks and other external media in units called files.

Presented by Vinod Gandhi

41

File System
Commonly, files represent programs (both source and object form) OR files are an abstraction mechanism. they provide a way to store information on the disk and read it back later. File mapped on physical device by the operating system, these storage devices are usually nonvolatile, so the contents are persistent through power failures and system reboots. Almost all information stored in a computer must be in a file.

Presented by Vinod Gandhi

42

File Structures
files can be structured in any of several ways.
1. 2. 3.

Byte sequence. Record sequence. Tree.

Presented by Vinod Gandhi

43

y Byte Sequence: is an unstructured sequence of bytes. File structure continue not know or care what is inIn effect, the operating system does the file.

All it sees are bytes, any meaning must be imposed by user-level programs. Both UNIX and MS-DOS use this approach.

y Record Sequence: in this sequence a file is a fixed-length

record, each with some internal structure. Central to the idea of a file being a sequence of records is the idea that the read operation returns one record and the write operations overwrites or appends one record. necessarily all the same length, each containing a key filed in a fixed position in the record. The tree is sorted on the key field, to allow rapid searching for a particular key...

y Tree: in this organization, a file consists of a tree of records, not

Presented by Vinod Gandhi

44

Files Access Methods


y

Sequential Access: In these systems a process could read all the bytes or records in a file in order Random Access: Files whose bytes or records can be read in any order are called random access file.

Presented by Vinod Gandhi

45

File Types
y

Regular files
are the once that contain user information.

Character special files


are related to input/output and used to model serial i/o devices such as terminals printers and networks.

Block special files


are used to model disks

Presented by Vinod Gandhi

46

File Attributes
y Every file has a name and its data. For example, the date and time the file was created or the file s size. We will call these extra items the file s attributes.

Presented by Vinod Gandhi

47

File Attributes Continue


y y y y y y

Name: only information kept in human-readable form. Type: needed for systems that support different types Location: pointer to file location on device Size: current file size Protection: controls who can do reading, writing, executing Time, Date, And User Identification: data for protection, security, and usage monitoring Information About Files Are Kept in the directory structure, which is maintained on the disk

Presented by Vinod Gandhi

48

File Operations
Files exist to store information and allow it to be retrieved later. Different systems provide different operations to allow storage and retrieval. Here is some common system operations relating to files these are...

Presented by Vinod Gandhi

49

File operations continue .


y

Create: the file is created with no data. The purpose of the call is to announce that the file is coming and to set some of the attributes... Delete: when the file is no longer needed, it has to be deleted to free up disk space. Three is always a system cal for this purpose. Open: before using a file, a process must open it. The purpose of the OPEN call is to allow the system to fetch the attributes and list of disk address into main memory for rapid access on later calls. Close: the file closing mean to free up internal table space. Read: data are from file. Usually the bytes come form the current position. The caller must specify how much data are needed and must also provide a buffer to put them in.

y y

Presented by Vinod Gandhi

50

y Write: data continue usually current File operationsare written to the file, again,the fill s at theincreases.position. If the current position is the end of the file, size If the current

position is in the middle of the file. Existing data are overwritten and lost forever.

y Append: Mixing and merging the data of two or multi files and add them at the

end of the file.

y Seek: for random access files. Method is needed to specify from where to take

the data. Also mean searching and finding of data.

y Get Attributes: it s about the honor and modification times. Cause professes

often need to read file attributes to do their work. the file has been created.

y Set Attributes: Some of the attributes are user settable and can be changed after y Rename: if frequently happens that a user need to change the name of an

existing file.

Presented by Vinod Gandhi

51

File Sharing
y y y y

Sharing of files on multi-user systems is desirable Sharing may be done through a protection scheme On distributed systems, files may be shared across a network Network File System (NFS) is a common distributed file-sharing method

y User IDs
identify users, allowing permissions and protections to be per-user

y Group IDs
allow users to be in groups, permitting group access rights

Presented by Vinod Gandhi

52

File Sharing Remote File Systems


y Uses networking to allow file system access between systems
y Manually via programs like FTP y Automatically, seamlessly using distributed file systems y Semi automatically via the world wide web

Presented by Vinod Gandhi

53

File Sharing Failure Modes


y Remote file systems add new failure modes, due to network failure,

server failure
y Recovery from failure can involve state information about status of each

remote request
y Stateless protocols such as NFS include all information in each request,

allowing easy recovery but less security

Presented by Vinod Gandhi

54

Protection
File owner/creator should be able to control
what can be done by whom ?

Types of access
1. 2. 3. 4. 5. 6.

Read Write Execute Append Delete List

Presented by Vinod Gandhi

55

Directories
To keep track of files, file system normally have directories, which , in many systems, are themselves files.

Presented by Vinod Gandhi

56

Information in a Device Directory


y y y y y y y y y

Name Type Address Current length Maximum length Date last accessed (for archival) Date last updated (for dump) Owner ID Protection information (discuss later)

Presented by Vinod Gandhi

57

Operations Performed on Directory


y Search for a file y Create a file y Delete a file y List a directory y Rename a file y Traverse the file system

Presented by Vinod Gandhi

58

Organize the Directory (Logically) to Obtain


y y

Efficiency
locating a file quickly

Naming
convenient to users y Two users can have same name for different files y The same file can have several different names

Grouping
logical grouping of files by properties, (e.g., all Java programs, all games, )

Presented by Vinod Gandhi

59

Types of directories
1.

Single level directory.


1. 2.

All files in the same directory. Unique name.

2.

Two level directory.


1.

Separate Directory for each user.

3.

Three structure directories.


1.

Here user can create their own directories and to organize their files accordingly.

4.

Acyclic-Graph Directories
1.

Shared directory (Two programmers)

Presented by Vinod Gandhi

60

What is Linux?
Linux is a true 32-bit operating system that runs on a variety of different platforms, including Intel, Spark, Alpha, and Power-PC (on some of these platforms, such as Alpha, Linux is actually 64-bit).

Presented by Vinod Gandhi

61

Linux introduction
the same time)
y Command line/Gui y Open Office (By default office) y My Sql

y Multi-user and multitasking operating system.( seven user can work at

y Open Source (code freely available, either from internet) y Administrator (root)

Presented by Vinod Gandhi

62

Linux user accounts




How Linux user accounts work Where Linux user accounts are stored Creating and managing user accounts from the command line

Presented by Vinod Gandhi

63

How Linux User Accounts Work




By default, all user home directories are created and maintained in the /home directory. However, the root user s home directory is /root

Presented by Vinod Gandhi

64

y Information about user.


finger user_name the following information about the user will be displayed. Login This is the username that is used to authenticate to the system. Name This is the user s full name. Directory This is the user s home directory. Last Login This displays the last time the user logged in and where from.

Presented by Vinod Gandhi

65

LINUX
y the first regular user account created on the system is always assigned a

UID of 1000. The next user account will be assigned a UID of 1001...
y The root user account is always assigned a UID of 0 on most Linux

distributions.

Presented by Vinod Gandhi

66

Where Linux User flexible operating system. One of its flexible features is Accounts Are Stored y Linux is a very
the location of user accounts on the system. When you originally installed the system, your distribution may have given you several options for where you wanted to store your user accounts.
y /etc/passwd file. This has been the default configuration used by Linux

systems for many years.


y NIS This option stands for Network Information Service or user network

management.this option will also show that how many user I have in a network.
y Windows domin: used for share purposes.

Presented by Vinod Gandhi

67

Local option
y /etc/passwd This file contains the user account information for your

system.
y /etc/shadow This file contains passwords for your user accounts. y /etc/group This file contains your system s groups.

Presented by Vinod Gandhi

68

The /etc/passwd File




Username:Password:UID:GID:Full_Name:Home_Directory:Default_Shel Username: The Username field simply identifies the username the user will supply when logging in to the system Password: This is a legacy field. At one time, the user s password was stored in encrypted form in this field in the passwd file. However, for security reasons, the password has been moved from /etc/passwd to /etc/shadow. UID This is the user ID for the user account GID This field references the group ID number of the user s default group Full_Name This field contains the user s full name Home_Directory This field contains the path to the user s home directory. Default_Shell This field specifies the shell that will be used by default

y y y y y

Presented by Vinod Gandhi

69

Username:Password:Last_Modified:Min_Days:Max_Days:Days_Warn: The /etc/shadow File Disabled_Days:Expire


y y

Username This is the user s login name from /etc/passwd.

y Password This is the user s password in encrypted format y Last_Modified This field displays the number of days since January 1,

1970 that the password was last changed

y Min_Days This field displays the minimum number of days required

before a password can be changed. In this example, it is set to 0 days.

y Max_Days This field displays the maximum number of days before a

password must be changed. In this example, it is set to 99999 days. Effectively, this means a password isn t required.

y Days_Warn This field displays the number of days prior to password

expiration that the user will be warned of the pending expiration. In this case, it s set to 7 days.

Presented by Vinod Gandhi

70

Commands.
y Disabled_Days This field displays the number of days to wait after a password has

expired to disable the account.

y Expire This field displays the number of days since January 1, 1970 after which the

account will be disabled. In this example, it is set to a null value, indicating the account never expires.

y To verify your /etc/passwd and /etc/shadow files, you can use the pwck command

at the shell prompt. This utility will verify each line in the two files and make sure they are valid. Any errors are reported on the screen.

Presented by Vinod Gandhi

71

Creating and Managing User Accounts from the Command Line


y Using useradd y Using passwd y Using usermod y Using userdel

Useradd Ahmed password ABC.

Presented by Vinod Gandhi

72

Using usermod
y From time to time, you will need to modify an existing user account. The syntax

for usermod is very similar to that used by useradd. Syntax: usermod options username

Using userdel
Syntax: userdel username

Presented by Vinod Gandhi

73

y groups from the ManagingUsing groupadd command line


Syntax: groupadd options groupname

y Using groupmod
y Syntax:

groupmod options group

y Using groupdel
Syntax: groupdel group_name

Presented by Vinod Gandhi

74

Manage ownership, permissions, and quotas

y Managing ownership y Managing permissions y Implementing disk quotas

Presented by Vinod Gandhi

75

FAQ Sy

Why to share memory between processes ?

y How do processes behave ? y What is a Real-Time Operating System? y How does system perform translation ? y What are the two main function of OS? y What advantage is there in having different time-quantum sizes

on different levels of a multilevel queuing system?

y Why paging is used?

Presented by Vinod Gandhi

76

Vous aimerez peut-être aussi