Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Survey Paper # 1 Modern Operating Systems Unix by Sajida Begum Samina F Choudhry.

Similar presentations


Presentation on theme: "1 Survey Paper # 1 Modern Operating Systems Unix by Sajida Begum Samina F Choudhry."— Presentation transcript:

1 1 Survey Paper # 1 Modern Operating Systems Unix by Sajida Begum Samina F Choudhry

2 2 Outline Brief History of UNIX Goals of UNIX Processes and Processes Management Memory Management File System Architecture and Management Interprocess Communication

3 3 Brief History of UNIX 1960’s : MULTICS ( Multiplexed Operating and Computing System) by General Electric, Massachusetts Institute for Technology and Bell Laboratories 1969: UNICS (Uniplexed Operating and Computing System )by Bell Labs.Though the OS has changed, the name stuck and was shortened to Unix 1973 : rewritten in ‘C’ language. 1974 : 5 th addition of UNIX 1978 : 7 th addition ; a dividing point for SVR4(System V) and BSD BSD : Berkley version of UNIX Linux :Borrows from both SVR4 and BSD

4 4 Features of UNIX UNIX is an operating system made by programmers to programmers.  Multitasking capability.  Multi-user capability.  Portability.  Easy to understand.  Written in High-level language rather that assembly language.  Open system. 

5 5 Processes & Process Management Process : The process is OS abstraction for execution. - A process is a program (file). - It is a unit of execution. - It is a dynamic execution context of a program. A process is sometimes called a job or a task or a sequential process. A sequential process is a program in execution -It defines the sequential, instruction-at-a-time execution of a program.

6 6 Process Components A process contains all of the state for a program in execution. An address space. The code for the executing program. The data for the executing program. An executing stack encapsulating the state of procedure calls. The program counter (PC) indicating the next instruction. A set of general-purpose registers with current value. Operating system resources like open file, n/w connections etc.

7 7 Process state The process has an execution state that indicates what it is doing currently ? Running : Executing instructions on the CPU - It is the process that has control of the CPU. Ready : Waiting to be assigned to the CPU - Ready to execute but another program is executing on the CPU. Waiting : Waiting for an event, eg. I/O completion - It cannot make progress until event is signaled. Stopped : Not allowed to execute. As a process executes it moves from state to state

8 8 Process state Graph New Ready TerminatedRunning Waiting Create Process I/O Done I/O Page fault etc. Schedule Process Unscheduled Process Exit

9 9 Process Creation in UNIX A process is created by another process. - Parent is creator and child is created - Process user id is inherited - After creating a child the parent may either wait for it to finish its task or continue in parallel or both. The processes are created using fork() int fork() Fork() Creates and initializes a new PCB.(Process Control Block) Creates a new address space. Initializes the address space with a copy of the entire contents of the address space of the parent. Initializes the kernel resources to point to the resources used by parent (eg., open file). Places the PCB in the ready queue.

10 10 Fork Int main( int argc, char *argv[]) { char *name = argv[0]; int child_pid = fork(); if(child_pid == 0) { printf(“Child of %s is %d\n”, name,getpid()); return 0; }else { printf(“My child is %d\n”, child_pid) return 0; } } // What does this program prints ?

11 11 Fork Output:  My child is 486 Duplicating Address: // Child_pid = 486 // Child_pid = 0 Child_pid = fork(); if(child_pid == 0) { if(child_pid == 0){ printf(“Child “); printf(“Child”); }else { printf(“Parent”); printf(“Parent”); } } // Parent // Child

12 12 Parents & Child processes The processes which call fork( ) is the parent. The process which result from the fork( ) is the child. Fork( ) returns ‘0’ if the process is the child process Fork ( ) returns the PID of the child if the process is the parent process. In UNIX all the processes ultimately come from the init process (PID = 1)

13 13 Long-Term Processes: Daemons Daemon: Daemon processes run in the background and spend most of their time waiting for an event to occur, which they provide them service these are started automatically when the system is booted. a typical daemon …cron daemon daemons are needed to : -schedule activities -startup periodic activities

14 14 Process Management Description Pid = fork()Create a child process S=waitpid(pid,&status,opts)Wait for a child to terminate S= execve(name, argv, envp)Replace a process core image Exit(status)Terminate execution and return status S= sigaction(sig, &act,&oact)Specify action to take for a signal S= kill (pid, sig)Send a signal to a process Residual = alarm (seconds)Schedule a sig alarm signal later Pause( )Suspend the caller unit the next signal

15 15 Memory Management in UNIX The memory management subsystem is one of the most important parts of the operating system. It allows: Large Address Spaces Protection. Memory Mapping Fair Physical Memory Allocation Shared Virtual Memory

16 16 Cont’d Physical vs. Virtual Memory What is a Page Memory? Cache Memory How the Kernel Organize Memory - Dividing the RAM - System and User Areas Paging vs. Swapping

17 17 File System in Unix Introduction What is File System? –The abstraction used by kernel to represent and organize the storage resources. UNIX File System in general –File system is organized in tree structure. –File tree can be arbitrarily deep. –File name must NOT LONGER than 256 chars. –Single path name must NOT LONGER than 1023 chars.

18 18 Creating File System Mounting File System –File tree is composed of File System –Use mount command to map a directory within the existing file tree (mount point) to the root of the new file system. mount /dev/hda2 /usr –Use umount command to detach the file system. Detaching will fail if the file system is busy.

19 19 Types of files Every thing in Unix is a file. There are 3 types of files: Regular files, Directory files and Device files. 1.Regular files: Most common type. Hold programs and data. Example - Source code of a program - Email received from a friend - Executable programs and applications such as (ls, cat etc.,)

20 20 Types of files cont.. 2. Directory files: A directory is like a file folder, it can contain files, and other directories and hold programs and data. Like a cabinet in real life, the files that contains other files. Saves information of files such as location, size etc., A directory in the file system tree may have many children, but it can only have one parent.

21 21 Types of files (cont.) 3. Device Files: 1. Allows programs to communicate with the hardware. 2. Kernel modules handles device management. - Character Device Accepts a stream of characters, without regard to any block structure. It is not addressable, therefore no seek operation - Block Device Information stored in fixed-sized block. It is addressable, therefore seek operation is possible.

22 22 Types of files cont.. Device files (cont..) Devices are also represented by special files. Each hardware is treated as a file like: Terminals, keyboards, printers etc. Example: - read the user input from the keyboard device - print a text file: copy a file to the printer device

23 23 Organizing of The File System

24 24 File System Structure / binetcusr user lib admin staffstud jonstev

25 25 File Structure cont.. Absolute path: The path to a location can be defined as an absolute path from the root anchor point. Relative path: The path starting from the current location. Current working directory: The place in the filesystem tree where you are located is called the current working directory.

26 26 INODES –Kernel maintains file information in a structure called inode. Creation, modification time stamps Ownership, file size etc. –Commonly used INODE information can be found by using ls command –Group information and be modified by using chgrp command.

27 27 File Management File: File is a collection of permanent data with a global name. - The data are permanent in the sense that they remain in existence until they are destroyed explicitly by a process or a user (through some process). - The name is global in the sense that it does not belong to the address space. they have a name the name refers to some data the data may be examined or modified access to the name and the data is controlled

28 28 File and Directory permissions Three class of users and three types of permissions. Classes of Users: Owner : I created the file. Group : The owner and I are in the same working group. World : I just want to use the file. Types of Permissions: Read permission : Read. Write permission : Alter, add or delete. Execute permission : Run.

29 29 Access Methods Definition: An access method defines the way processes read and write files. 1.Sequential Access:The file is associated with a read/write mark, which is advanced on each access. If several processes are reading or writing from the same file, then the system may define one read/write mark or several. 2.Direct Access: This access allows a user to position the read/write mark before reading or writing. This feature is useful for applications such as editors that need to randomly access the contents of the file.

30 30 Access Methods cont.. 3. Mapped Access:When a process opens a file, it is mapped to a segment. The open call returns the number of this segment. The process can thus access the file as part of its virtual store. 4. Structured Files:. Database applications often wish to treat them as records that may be accessed by some key. To accommodate these applications, some systems support typed or structured files that are considered streams of records

31 31 Interprocess Communication using Unix Domain Socket: A socket is an endpoint of communication between processes. It is a software entity that provides the basic building block for interprocess communications. Sockets function either as clients or servers. A server typically advertises some service at a well- known address and waits for clients to request connections. Clients requiring a particular service attempt to connect to a server at the server's advertised transport address.

32 32 Unix Domain Sockets Types of Sockets: Unix Domain Socket : UNIX domain sockets communicate between processes on the same system only. Internet domain sockets : which can be used to communicate with processes on other systems Two types of Unix Domain Sockets: 1.Stream sockets : Most commonly used socket, It provides bi-directional, sequenced, and unduplicated flow of data without boundaries. - This service is reliable and connection-oriented. - Data is transmitted on a full-duplex, flow- controlled byte stream.

33 33 Unix Domain sockets cont.. Cont.. - Message boundaries are not preserved on a stream socket. - it is supported by the Internet transport protocol TCP. 2. Datagram sockets:A datagram service is connectionless and unreliable. - used in applications where reliability of an individual packet is not essential. - message boundaries are maintained. This means that individual datagrams (i.e., messages sent with separate calls) will be kept separate when they are received at the other end. - it is supported by the Internet transport protocol UDP.

34 34 How to create a socket ? s = socket(domain, type, protocol); domain :The domain is specified as a manifest constant. Type, Types are: SOCK_STREAM and SOCK_DGRAM Protocol: is a set of communication conventions for regulating the exchange of information between two parties eg. TCP, UDP.


Download ppt "1 Survey Paper # 1 Modern Operating Systems Unix by Sajida Begum Samina F Choudhry."

Similar presentations


Ads by Google