Download presentation
Presentation is loading. Please wait.
1
Avani R.Vasant V.V.P. Engineering College
Concepts of OS Some of the Operating Systems Concepts Process Deadlocks Memory Management Input / Output Files Security The Shell System Calls 6/15/2018 Avani R.Vasant V.V.P. Engineering College
2
Avani R.Vasant V.V.P. Engineering College
Process It is a Key Concept in OS. A Process is a Program in execution. Each process has its address space. List of memory locations, which process can read and write. Address Space Contains The executable program & its data Its stack Each process has set of registers program counters Stack Pointer Other H/W registers & Information to run the program. Ex. Of process Batch Job Time-Shared user program Spooling output to a printer 6/15/2018 Avani R.Vasant V.V.P. Engineering College
3
Avani R.Vasant V.V.P. Engineering College
Process Cont… Time-Sharing System OS decides to stop running one process and start another process (CPU Sharing) Suspended process must later be re-started in the same state, where it was stopped All the Information must be stored somewhere before suspension Process may have several files open for the reading Associated with each file a pointer giving the current position (no. of bytes to be read next) All these pointers must be saved before suspension so that a read call can read the proper data at the time of resumption. 6/15/2018 Avani R.Vasant V.V.P. Engineering College
4
Avani R.Vasant V.V.P. Engineering College
Process Cont… Process Table: In many OS the Information about process (other than address space) is stored in an OS table called the process table The Key process mgmt system calls are those dealing with the creation and termination of process. Process can create another process (Child process) 6/15/2018 Avani R.Vasant V.V.P. Engineering College
5
Avani R.Vasant V.V.P. Engineering College
Process Cont… Ex: Shell reads command from a terminal A programmer types a command requesting that a program be compiled Shell must create new process that will run the compiler When process has finished it executes a system call to terminated itself. Processes that cooperate to get some Job done often need to communicate with one another and synchronize their activities Communication is called IPC ( Inter Process Communication.) UID User Identification PID Process Identification (child has the same UID as its parent) GID Group Identification 6/15/2018 Avani R.Vasant V.V.P. Engineering College
6
Avani R.Vasant V.V.P. Engineering College
Deadlock When two or more processes are interacting, they sometimes get into a stalemate situation they cannot get out of Such a situation is called Deadlock. Deadlock in traffic 6/15/2018 Avani R.Vasant V.V.P. Engineering College
7
Avani R.Vasant V.V.P. Engineering College
Deadlock Processes in a computer can experience an analogous situation in which they cannot make any progress. Ex Tape Drive and CD-ROM Process 1 requests for Tape Drive and gets it. Process 2 requests for CD-ROM and gets it. Now, Process1 wants CD-ROM drive so suspended Process 2 wants Tape Drive so suspended DEADLOCK FOREVER 6/15/2018 Avani R.Vasant V.V.P. Engineering College
8
Avani R.Vasant V.V.P. Engineering College
Memory Management Every Computer has Main Memory and it is Central to every Computer It holds programs which is executing Repository of quickly accessible data shared by CPU & I/O devices CPU & I/O reads & Writes data to and from memory In Simple OS one program in memory if second needs then one has to be to be removed Development in OS handles multiple programs in memory, programs do not interfere each other so some protection mechanism is required. Managing & Protecting the Computer Memory Managing & Protecting the address space of each process What if Process needs more address space than the memory size? In early days was not possible, but now Virtual Memory is the answer Part of process is on disk and part of process is in memory so OS handles the things using different algorithms. 6/15/2018 Avani R.Vasant V.V.P. Engineering College
9
Avani R.Vasant V.V.P. Engineering College
Memory Management OS is responsible for Keeps track of which part of memory is currently in use and by whom Decides which processes to be loaded in the memory when the space is available Allocate & Deallocate memory space as needed 6/15/2018 Avani R.Vasant V.V.P. Engineering College
10
Avani R.Vasant V.V.P. Engineering College
Input / Output All Computers have devices for I/P and O/P Ex. Keyboard, Monitors, Printers etc. OS manages all this devices. OS hides the peculiarities of Hardware devices from the users. Device driver Interface Drivers specific to each H/W devices Buffering, caching & spooling 6/15/2018 Avani R.Vasant V.V.P. Engineering College
11
Avani R.Vasant V.V.P. Engineering College
Files Another Key Concept supported by all OS is file system To hide everything System Calls are needed to create files, remove files, read files & write files. Before a file is read, it must be located on the disk & opened, after that it has been read & it should be closed. Calls are used to do these things also. Directory To provide a place to keep files, A concept used by the OS is the directory as a way of grouping files together 6/15/2018 Avani R.Vasant V.V.P. Engineering College
12
Files Figure 1. A file system for a university department. 6/15/2018
Avani R.Vasant V.V.P. Engineering College
13
Avani R.Vasant V.V.P. Engineering College
Files System calls are needed to create & remove directories Calls are needed to put an existing files in a directory & remove from a directory Directory entries are directory or files Process VS File (both can be shown by trees) Process hierarchies are not deep(2-3) where as files can be Process hierarchies are short-lived (few mins) where as files/ Dir exists for the years Parent/Child can only access the process where files can be accessible to wider groups Pathname Root directory to the file /faculty/Avani/ppts/os is a Path If working directory is /faculty/Avani then req path is /ppts/os 6/15/2018 Avani R.Vasant V.V.P. Engineering College
14
Avani R.Vasant V.V.P. Engineering College
Files Before a file can be read or written it must be opened and checked for the permissions If Access is permitted then the system returns a small integer called a File Descriptor to use in subsequent operations Otherwise error code will be generated. Mount Call For Floppies, CD-ROMs , Pen Drives etc 6/15/2018 Avani R.Vasant V.V.P. Engineering College
15
Avani R.Vasant V.V.P. Engineering College
Mount Call Figure 2. (a) Before mounting, the files on the CD-ROM are not accessible. (b) After mounting, they are part of the file hierarchy. 6/15/2018 Avani R.Vasant V.V.P. Engineering College
16
Special Files Pipe Figure 3 Two processes connected by a pipe.
I/O devices look like files Block Special Files Ex disks Character Special Files Ex Printers, Modems etc. / dev directory /dev/lp Pipe A pipe is a sort of pseudo file that can be used to connect two processes Figure 3 Two processes connected by a pipe. 6/15/2018 Avani R.Vasant V.V.P. Engineering College
17
Avani R.Vasant V.V.P. Engineering College
Files OS is responsible for Creation & deletion of Files Creation & deletion of Directories Support for manipulating Files Mapping files on secondary storage Back up of files on storage media 6/15/2018 Avani R.Vasant V.V.P. Engineering College
18
Avani R.Vasant V.V.P. Engineering College
Security Computer Contains large amount of information that user wants to keep confidential s, business plans, tax returns etc OS manages security so that it is only accessible to authorized users Unix uses 9-bit binary code for protection mechanism rwxr-x—x Owner, group, others(everyone) Protection from users and viruses also to be handled 6/15/2018 Avani R.Vasant V.V.P. Engineering College
19
Avani R.Vasant V.V.P. Engineering College
The Shell Command Interpreter or called The Shell It is a primary interface between a user sitting at his terminal and the OS Many shells exists Sh, csh, ksh, bash When user logs in a shell is started up Shell has the terminal as standard I/P and standard O/P When u get dollar sign means shell is working It tell the user that shell is waiting to accept a command 6/15/2018 Avani R.Vasant V.V.P. Engineering College
20
Avani R.Vasant V.V.P. Engineering College
The Shell Ex date Shell creates a child process and runs the date program as child While child is running shell waits for it to terminate When it finishes, shell returns the prompt & again tries to read the next I/P Ex date > file Ex sort < file1 > file2 Ex cat file1 file2 file3 | sort > /dev/lp Ex cat file1 file2 file3 | sort > /dev/lp & Runs the job in background and user can get the prompt to work 6/15/2018 Avani R.Vasant V.V.P. Engineering College
21
Avani R.Vasant V.V.P. Engineering College
System Calls The Interface between the OS and the user program is defined by the set of system calls. System Calls vary from OS to OS We will look at the UNIX System Calls If a process is running a user program in user mode and needs a system services, such as reading data from a file, it has to execute a trap or system call instruction to transfer control to the OS Then OS checks the parameters and carries out the system call Then returns control to the instruction following the system call It is like a procedure call 6/15/2018 Avani R.Vasant V.V.P. Engineering College
22
Avani R.Vasant V.V.P. Engineering College
System Calls Figure 4. The 11 steps in making the system call read (fd, buffer, nbytes). 6/15/2018 Avani R.Vasant V.V.P. Engineering College
23
Avani R.Vasant V.V.P. Engineering College
Read System Call Calling program pushes the parameters onto the stack (Step 1-3) Then actual call to the library procedure is made (Step 4) Library procedures are in assembly language, typically puts the system call number in register (step 5) This executes TRAP instruction to switch from user mode to kernel mode. Start execution at a fixed address within the kernel (step 6) Kernel code starts examining the system call number & dispatches to the correct system call handler via a table with Handlers (step 7) Then system call handler runs (step 8) Once it is done control returned back to the user space following the TRAP (step 9) This procedure runs the user program (step 10) Then to finish the Job user program cleans up the stack (step 11) 6/15/2018 Avani R.Vasant V.V.P. Engineering College
24
System Calls for Process Management
Some of the major POSIX system calls. 6/15/2018 Avani R.Vasant V.V.P. Engineering College
25
System Calls for File Management (1)
Some of the major POSIX system calls. 6/15/2018 Avani R.Vasant V.V.P. Engineering College
26
System Calls for File Management (2)
Some of the major POSIX system calls. 6/15/2018 Avani R.Vasant V.V.P. Engineering College
27
Miscellaneous System Calls
Some of the major POSIX system calls. 6/15/2018 Avani R.Vasant V.V.P. Engineering College
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.