Chapter -2 Operating-System and its Structures

ChandrakantDivate1 112 views 65 slides May 09, 2024
Slide 1
Slide 1 of 65
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65

About This Presentation

Operating-System and its Structures


Slide Content

Chapte r 2 : Operating-System Structures Mr. C. P. Divate

Chapter 2: Operating-System Structures 2. Operating System Services User Operating System Interface System Calls Types of System Calls System Programs Operating System Design and Implementation Operating System Structure Operating System Debugging Operating System Generation System Boot

Operating System Services 2. User interface Program Execution I/ O Ope r ations File System manipulation Communications Error detection Resource Allocation Accounting Protection and Security

Operating System Services 2. Operating systems provide an environment for execution of programs and services to programs and users One set of operating-system services provides functions that are helpful to the user: User interface - Almost all operating systems have a user interface ( UI ). 4 Varies between Command-Line ( CLI ) , Graphics User Interface ( GUI ) , Batch Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error) I/O operations - A running program may require I/O, which may involv e a fil e o r a n I/ O device

Operating System Services (Cont.) 2. One set of operating-system services provides functions that are helpful to the user (Cont.): File-system manipulation - The file system is of particular interest. Programs need to read and write files and directories, create and delete them, search them, list file Information, permission management. Communications – Processes may exchange information, on the same computer or between computers over a network 4 Communications may be via shared memory or through message passing (packets moved by the OS) Error detection – OS needs to be constantly aware of possible errors 4 May occur in the CPU and memory hardware, in I/O devices, in user program 4 For each type of error, OS should take the appropriate action to ensure correct and consistent computing 4 Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system

Operating System Services (Cont.) 2. Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of them 4 Many types of resources - CPU cycles, main memory, file storage, I/ O devices. Accounting - To keep track of which users use how much and what kinds of computer resources Protection and security - The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other 4 Protection involves ensuring that all access to system resources is controlled 4 Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts

A View of Operating System Services 2.

User Operating System Interface - CLI 2. CLI or command interpreter allows direct command entry Sometimes implemented in kernel, sometimes by systems program Sometimes multiple flavors implemented – shells Primarily fetches a command from user and executes it Sometimes commands built-in, sometimes just names of programs

User Operating System Interface - GUI 2. User-friendly desktop metaphor interface Usually mouse, keyboard, and monitor Icons represent files, programs, actions, etc Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (known as a folder ) Many systems now include both CLI and GUI interfaces Microsoft Windows is GUI with CLI “command” shell Apple Mac OS X is “Aqua” GUI interface with UNIX kernel underneath and shells available Unix and Linux have CLI with optional GUI interfaces (CDE, KDE, GNOME)

Touchscreen Interfaces 2. Touchscreen devices require new interfaces Mouse not possible or not desired Actions and selection based on gestures Virtual keyboard for text entry Voice commands.

Layers of Abstraction

Operating System Mode The User Mode is concerned with the actual interface between the user and the system. It controls things like running applications and accessing files. The Kernel Mode is concerned with everything running in the background. It controls things like accessing system resources, controlling hardware functions and processing program instructions. System calls are used to change mode from User to Kernel.

Kernel Kernel is a software code that reside in central core of OS. It has complete control over system. When operation system boots, kernel is first part of OS to load in main memory. Kernel remains in main memory for entire duration of computer session. The kernel code is usually loaded in to protected area of memory. Kernel performs it’s task like executing processes and handling interrupts in kernel space. User performs it’s task in user area of memory. This memory separation is made in order to prevent user data and kernel data from interfering with each other. Kernel does not interact directly with user, but it interacts using SHELL and other programs and hardware .

Kernel cont … Kernel includes:- 1. Scheduler: It allocates the Kernel’s processing time to various processes. 2. Supervisor: It grants permission to use computer system resources to each process. 3. Interrupt handler : It handles all requests from the various hardware devices which compete for kernel services. 4. Memory manager : allocates space in memory for all users of kernel service. kernel provides services for process management, file management, I/O management, memory management. System calls are used to provide these type of services.

System Call System call is the programmatic way in which a computer program/user application requests a service from the kernel of the operating system on which it is executed. Application program is just a user-process. Due to security reasons , user applications are not given access to privileged resources(the ones controlled by OS). When they need to do any I/O or have some more memory or spawn a process or wait for signal/interrupt, it requests operating system to facilitate all these. This request is made through System Call. System calls are also called software-interrupts.

System Calls

How System Call Works? Step 1) The processes executed in the user mode till the time a system call interrupts it. Step 2) After that, the system call is executed in the kernel-mode on a priority basis. Step 3) Once system call execution is over, control returns to the user mode., Step 4) The execution of user processes resumed in Kernel mode.

Why do you need System Calls in OS? Following are situations which need system calls in OS: Reading and writing from files demand system calls. If a file system wants to create or delete files, system calls are required. System calls are used for the creation and management of new processes. Network connections need system calls for sending and receiving packets. Access to hardware devices like scanner, printer, need a system call.

I/O and File manipulation

Examples of I/O and file system calls

Types of System calls 2. Process control File management Device management Information maintenance Communications

Process control 2. End and Abort Load and Execute Create Process and Terminate Process Wait and Signal Event Allocate and free memory

File management 2. Create a file Delete file Open and close file Read, write, and reposition Get and set file attributes

Device management 2. Request and release device Logically attach/ detach devices Get and Set device attributes

communications 2. Communications : Message passing , shared memory Create delete communication connection Send , receive messages Transfer status information

Information maintenance 2. Get time or date , set time or date Get system data , set system data Ge t p r ocess Se t p r ocess

Important System Calls Used in OS for process control wait() In some systems, a process needs to wait for another process to complete its execution. This type of situation occurs when a parent process creates a child process, and the execution of the parent process remains suspended until its child process executes. The suspension of the parent process automatically occurs with a wait() system call. When the child process ends execution, the control moves back to the parent process. fork() Processes use this system call to create processes that are a copy of themselves. With the help of this system Call parent process creates a child process, and the execution of the parent process will be suspended till the child process executes. exec() This system call runs when an executable file in the context of an already running process that replaces the older executable file. However, the original process identifier remains as a new process is not built, but stack, data, head, data, etc. are replaced by the new process .

Important System Calls Used in OS for process control kill (): The kill() system call is used by OS to send a termination signal to a process that urges the process to exit. However, a kill system call does not necessarily mean killing the process and can have various meanings. exit(): The exit() system call is used to terminate program execution. Specially in the multi-threaded environment, this call defines that the thread execution is complete. The OS reclaims resources that were used by the process after the use of exit() system call.

Summary system calls: Categories Windows Unix Process control CreateProcess() ExitProcess() WaitForSingleObject() fork() exit() wait() Device manipulation SetConsoleMode() ReadConsole() WriteConsole() loctl() read() write() File manipulation CreateFile() ReadFile() WriteFile() CloseHandle() Open() Read() write() close()

Summary system calls: Categories Windows Unix Communication CreatePipe() CreateFileMapping() MapViewOfFile() Pipe() shm_open() mmap() Protection SetFileSecurity() InitlializeSecurityDescriptor() SetSecurityDescriptorGroup () Chmod () Umask () Chown ()

Components / Functions of Operating System

1. Process Management A process is a program in execution. A process needs certain resources, including CPU time, memory, files, and I/O devices to accomplish its task. Simultaneous execution leads to multiple processes. Hence creation, execution and termination of a process are the most basic functionality of an OS If processes are dependent , than they may try to share same resources. thus task of process synchronization comes to the picture. If processes are independent , than a due care needs to be taken to avoid their overlapping in memory area. Based on priority, it is important to allow more important processes to execute first than others .

Process management

Process management

Process management

2. Memory management

2. Memory management Memory is a large array of words or bytes, each with its own address. It is a repository of quickly accessible data shared by the CPU and I/O devices. Main memory is a volatile storage device. When the computer made turn off everything stored in RAM will be erased automatically. In addition to the physical RAM installed in your computer, most modern operating systems allow your computer to use a virtual memory system. Virtual memory allows your computer to use part of a permanent storage device (such as a hard disk) as extra memory. The operating system is responsible for the following activities in connections with memory management: Keep track of which parts of memory are currently being used and by whom. Decide which processes to load when memory space becomes available. Allocate and de-allocate memory space as needed.

2. Memory management

2. Memory management

2. Memory management: Paging In Operating Systems, Paging is a storage mechanism used to retrieve processes from the secondary storage into the main memory in the form of pages. The main idea behind the paging is to divide each process in the form of pages. The main memory will also be divided in the form of frames. One page of the process is to be stored in one of the frames of the memory. The pages can be stored at the different locations of the memory but the priority is always to find the contiguous frames or holes. Pages of the process are brought into the main memory only when they are required otherwise they reside in the secondary storage.

2. Memory management: Paging

2. Memory management: Paging

2. Memory management: Paging Let us consider that, P2 and P4 are moved to waiting state after some time. 

2. Memory management: Segmentation It is better to have segmentation which divides the process into the segments. Each segment contains the same type of functions such as the main function can be included in one segment and the library functions can be included in the other segment .

2. Memory management: Segmentation

2. Memory management

2. Memory management: Fixed Partitioning

2. Memory management: Dynamic Partitioning

2. Memory management: Fragmentation User processes are loaded and unloaded from the main memory, and processes are kept in memory blocks in the main memory. Many spaces remain after process loading and swapping that another process cannot load due to their size. Main memory is available, but its space is insufficient to load another process because of the dynamical allocation of main memory processes.

2. Memory management: External Fragmentation

2. Memory management: Swapping Swapping is a memory management scheme in which any process can be temporarily swapped from main memory to secondary memory so that the main memory can be made available for other processes. It is used to improve main memory utilization. In secondary memory, the place where the swapped-out process is stored is called swap space.

3. File Management A file is a collection of related information defined by its creator. File systems provide the conventions for the encoding, storage and management of data on a storage device such as a hard disk. FAT12 (floppy disks) FAT16 (DOS and older versions of Windows) FAT32 (older versions of Windows) NTFS (newer versions of Windows) EXT3 (Unix/Linux) HFS+ (Max OS X) The operating system is responsible for the following activities in connections with file management: ✦ File creation and deletion. ✦ Directory creation and deletion. ✦ Support of primitives for manipulating files and directories. ✦ Mapping files onto secondary storage. ✦ File backup on stable (nonvolatile) storage media.

3. File Management

3. File Management

3. File Management

3. File Management

Device Management or I/O Management

Device Management or I/O Management

Device Management or I/O Management

4. Device Management or I/O Management Device controllers are components on the motherboard (or on expansion cards) that act as an interface between the CPU and the actual device. Device drivers, which are the operating system software components that interact with the devices controllers. A special device (inside CPU) called the Interrupt Controller handles the task of receiving interrupt requests and prioritizes them to be forwarded to the processor. Deadlocks can occur when two (or more) processes have control of different I/O resources that are needed by the other processes, and they are unwilling to give up control of the device. It performs the following activities for device management. Keeps tracks of all devices connected to system. Designates a program responsible for every device known as Input/output controller. Decides which process gets access to a certain device and for how long. Allocates devices in an effective and efficient way. Deallocates devices when they are no longer required. 

5. Security & Protection The operating system uses password protection to protect user data and similar other techniques. It also prevents unauthorized access to programs and user data by assigning access right permission to files and directories. The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other.

6. User Interface Mechanism A user interface ( UI ) controls how you enter data and instructions and how information is displayed on the screen There are two types of user interfaces Command Line Interface Graphical user Interface

1. Command-line interface In a command-line interface, a user types commands represented by short keywords or abbreviations or presses special keys on the keyboard to enter data and instructions

2. Graphical User Interface With a graphical user interface (GUI), you interact with menus and visual images

End of Chapter 2
Tags