1st Unit of Operating System PDF

Summary

This document provides an overview of operating systems, including their history, characteristics, and functionalities. It covers topics like device management, file management, job accounting, and memory management.

Full Transcript

1st unit of operating system An operating system acts as an intermediary between the user of a computer and computer hardware. The purpose of an operating system is to provide an environment in which a user can execute programs conveniently and efficiently. An operating system is software that manag...

1st unit of operating system An operating system acts as an intermediary between the user of a computer and computer hardware. The purpose of an operating system is to provide an environment in which a user can execute programs conveniently and efficiently. An operating system is software that manages computer hardware. The hardware must provide appropriate mechanisms to ensure the correct operation of the computer system and to prevent user programs from interfering with the proper operation of the system. A more common definition is that the operating system is the one program running at all times on the computer (usually called the kernel), with all else being application programs. An operating system is concerned with the allocation of resources and services, such as memory, processors, devices, and information. The operating system correspondingly includes programs to manage these resources, such as a traffic controller, a scheduler, a memory management module, I/O programs, and a file system. History of Operating System The operating system has been evolving through the years. The following table shows the history of OS. Generation Year Electronic device used Types of OS Devices First 1945-55 Vacuum Tubes Plug Boards Second 1955-65 Transistors Batch Systems Third 1965-80 Integrated Circuits(IC) Multiprogramming Fourth Since 1980 Large Scale Integration PC Characteristics of Operating Systems Let us now discuss some of the important characteristic features of operating systems:  Device Management: The operating system keeps track of all the devices. So, it is also called the Input/Output controller that decides which process gets the device, when, and for how much time.  File Management: It allocates and de-allocates the resources and also decides who gets the resource.  Job Accounting: It keeps track of time and resources used by various jobs or users.  Error-detecting Aids: These contain methods that include the production of dumps, traces, error messages, and other debugging and error-detecting methods.  Memory Management: It keeps track of the primary memory, like what part of it is in use by whom, or what part is not in use, etc. and It also allocates the memory when a process or program requests it.  Processor Management: It allocates the processor to a process and then de-allocates the processor when it is no longer required or the job is done.  Control on System Performance: It records the delays between the request for a service and the system.  Security: It prevents unauthorized access to programs and data using passwords or some kind of protection technique.  Convenience: An OS makes a computer more convenient to use.  Efficiency: An OS allows the computer system resources to be used efficiently.  Ability to Evolve: An OS should be constructed in such a way as to permit the effective development, testing, and introduction of new system functions at the same time without interfering with service.  Throughput: An OS should be constructed so that It can give maximum throughput (Number of tasks per unit time). 1st unit of operating system Functionalities of Operating System  Resource Management: When parallel accessing happens in the OS means when multiple users are accessing the system the OS works as Resource Manager, Its responsibility is to provide hardware to the user. It decreases the load in the system.  Process Management: It includes various tasks like scheduling and termination of the process. It is done with the help of CPU Scheduling algorithms.  Storage Management: The file system mechanism used for the management of the storage. NIFS, CIFS, CFS, NFS, etc. are some file systems. All the data is stored in various tracks of Hard disks that are all managed by the storage manager. It included Hard Disk.  Memory Management: Refers to the management of primary memory. The operating system has to keep track of how much memory has been used and by whom. It has to decide which process needs memory space and how much. OS also has to allocate and deallocate the memory space.  Security/Privacy Management: Privacy is also provided by the Operating system using passwords so that unauthorized applications can’t access programs or data. For example, Windows uses Kerberos authentication to prevent unauthorized access to data. The process operating system as User Interface: 1. User 2. System and application programs 3. Operating system 4. Hardware Every general-purpose computer consists of hardware, an operating system(s), system programs, and application programs. The hardware consists of memory, CPU, ALU, I/O devices, peripheral devices, and storage devices. The system program consists of compilers, loaders, editors, OS, etc. The application program consists of business programs and database programs. Every computer must have an operating system to run other programs. The operating system coordinates the use of the hardware among the various system programs and application programs for various users. It simply provides an environment within which other programs can do useful work. The operating system is a set of special programs that run on a computer system that allows it to work properly. It performs basic tasks such as recognizing input from the keyboard, keeping track of files and directories on the disk, sending output to the display screen, and controlling peripheral devices. Purposes and Tasks of Operating Systems Several tasks are performed by the Operating Systems and it also helps in serving a lot of purposes which are mentioned below. We will see how Operating System helps us in serving in a better way with the help of the task performed by it. Purposes of an Operating System  It controls the allocation and use of the computing System’s resources among the various user and tasks.  It provides an interface between the computer hardware and the programmer that simplifies and makes it feasible for coding and debugging of application programs. Tasks of an Operating System 1. Provides the facilities to create and modify programs and data files using an editor. 2. Access to the compiler for translating the user program from high-level language to machine language. 3. Provide a loader program to move the compiled program code to the computer’s memory for execution. 4. Provide routines that handle the details of I/O programming. I/O System Management The module that keeps track of the status of devices is called the I/O traffic controller. Each I/O device has a device handler that resides in a separate process associated with that device. The I/O subsystem consists of 1st unit of operating system  A memory Management component that includes buffering caching and spooling.  A general device driver interface. Components of an Operating Systems There are two basic components of an Operating System.  Shell  Kernel Shell Shell is the outermost layer of the Operating System and it handles the interaction with the user. The main task of the Shell is the management of interaction between the User and OS. Shell provides better communication with the user and the Operating System Shell does it by giving proper input to the user it also interprets input for the OS and handles the output from the OS. It works as a way of communication between the User and the OS. Kernel The kernel is one of the components of the Operating System which works as a core component. The rest of the components depends on Kernel for the supply of the important services that are provided by the Operating System. The kernel is the primary interface between the Operating system and Hardware. Functions of Kernel The following functions are to be performed by the Kernel.  It helps in controlling the System Calls.  It helps in I/O Management.  It helps in the management of applications, memory, etc. Advantages of Operating System  It helps in managing the data present in the device i.e. Memory Management.  It helps in making the best use of computer hardware.  It helps in maintaining the security of the device.  It helps different applications in running them efficiently. Disadvantages of Operating System  Operating Systems can be difficult for someone to use.  Some OS are expensive and they require heavy maintenance.  Operating Systems can come under threat if used by hackers. Types of Operating Systems There are several types of Operating Systems which are mentioned below.  Batch Operating System  Multi-Programming System  Multi-Processing System  Multi-Tasking Operating System  Time-Sharing Operating System  Distributed Operating System  Network Operating System  Real-Time Operating System 1. Batch Operating System This type of operating system does not interact with the computer directly. There is an operator which takes similar jobs having the same requirement and groups them into batches. It is the responsibility of the operator to sort jobs with similar needs. 1st unit of operating system Batch Operating System Advantages of Batch Operating System  It is very difficult to guess or know the time required for any job to complete. Processors of the batch systems know how long the job would be when it is in the queue.  Multiple users can share the batch systems.  The idle time for the batch system is very less.  It is easy to manage large work repeatedly in batch systems. Disadvantages of Batch Operating System  The computer operators should be well known with batch systems.  Batch systems are hard to debug.  It is sometimes costly.  The other jobs will have to wait for an unknown time if any job fails. Examples of Batch Operating Systems: Payroll Systems, Bank Statements, etc. 2. Multi-Programming Operating System Multiprogramming Operating Systems can be simply illustrated as more than one program is present in the main memory and any one of them can be kept in execution. This is basically used for better execution of resources. MultiProgramming Advantages of Multi-Programming Operating System  Multi Programming increases the Throughput of the System.  It helps in reducing the response time. Disadvantages of Multi-Programming Operating System  There is not any facility for user interaction of system resources with the system. 1st unit of operating system 3. Multi-Processing Operating System Multi-Processing Operating System is a type of Operating System in which more than one CPU is used for the execution of resources. It betters the throughput of the System. Multiprocessing Advantages of Multi-Processing Operating System  It increases the throughput of the system.  As it has several processors, so, if one processor fails, we can proceed with another processor. Disadvantages of Multi-Processing Operating System  Due to the multiple CPU, it can be more complex and somehow difficult to understand. 4. Multi-Tasking Operating System Multitasking Operating System is simply a multiprogramming Operating System with having facility of a Round-Robin Scheduling Algorithm. It can run multiple programs simultaneously. There are two types of Multi-Tasking Systems which are listed below.  Preemptive Multi-Tasking  Cooperative Multi-Tasking  Multitasking Advantages of Multi-Tasking Operating System  Multiple Programs can be executed simultaneously in Multi-Tasking Operating System.  It comes with proper memory management. 1st unit of operating system Disadvantages of Multi-Tasking Operating System  The system gets heated in case of heavy programs multiple times. 5. Time-Sharing Operating Systems Each task is given some time to execute so that all the tasks work smoothly. Each user gets the time of the CPU as they use a single system. These systems are also known as Multitasking Systems. The task can be from a single user or different users also. The time that each task gets to execute is called quantum. After this time interval is over OS switches over to the next task. Time-Sharing OS Advantages of Time-Sharing OS  Each task gets an equal opportunity.  Fewer chances of duplication of software.  CPU idle time can be reduced.  Resource Sharing: Time-sharing systems allow multiple users to share hardware resources such as the CPU, memory, and peripherals, reducing the cost of hardware and increasing efficiency.  Improved Productivity: Time-sharing allows users to work concurrently, thereby reducing the waiting time for their turn to use the computer. This increased productivity translates to more work getting done in less time.  Improved User Experience: Time-sharing provides an interactive environment that allows users to communicate with the computer in real time, providing a better user experience than batch processing. Disadvantages of Time-Sharing OS  Reliability problem.  One must have to take care of the security and integrity of user programs and data.  Data communication problem.  High Overhead: Time-sharing systems have a higher overhead than other operating systems due to the need for scheduling, context switching, and other overheads that come with supporting multiple users.  Complexity: Time-sharing systems are complex and require advanced software to manage multiple users simultaneously. This complexity increases the chance of bugs and errors.  Security Risks: With multiple users sharing resources, the risk of security breaches increases. Time-sharing systems require careful management of user access, authentication, and authorization to ensure the security of data and software. Examples of Time-Sharing OS with explanation  IBM VM/CMS: IBM VM/CMS is a time-sharing operating system that was first introduced in 1972. It is still in use today, providing a virtual machine environment that allows multiple users to run their own instances of operating systems and applications.  TSO (Time Sharing Option): TSO is a time-sharing operating system that was first introduced in the 1960s by IBM for the IBM System/360 mainframe computer. It allowed multiple users to access the same computer simultaneously, running their own applications.  Windows Terminal Services: Windows Terminal Services is a time-sharing operating system that allows multiple users to access a Windows server remotely. Users can run their 1st unit of operating system own applications and access shared resources, such as printers and network storage, in real-time. 6. Distributed Operating System These types of operating system is a recent advancement in the world of computer technology and are being widely accepted all over the world and, that too, at a great pace. Various autonomous interconnected computers communicate with each other using a shared communication network. Independent systems possess their own memory unit and CPU. These are referred to as loosely coupled systems or distributed systems. These systems’ processors differ in size and function. The major benefit of working with these types of the operating system is that it is always possible that one user can access the files or software which are not actually present on his system but some other system connected within this network i.e., remote access is enabled within the devices connected in that network. Distributed OS Advantages of Distributed Operating System  Failure of one will not affect the other network communication, as all systems are independent of each other.  Electronic mail increases the data exchange speed.  Since resources are being shared, computation is highly fast and durable.  Load on host computer reduces.  These systems are easily scalable as many systems can be easily added to the network.  Delay in data processing reduces. Disadvantages of Distributed Operating System  Failure of the main network will stop the entire communication.  To establish distributed systems the language is used not well-defined yet.  These types of systems are not readily available as they are very expensive. Not only that the underlying software is highly complex and not understood well yet. Examples of Distributed Operating Systems are LOCUS, etc. 7. Network Operating System These systems run on a server and provide the capability to manage data, users, groups, security, applications, and other networking functions. These types of operating systems allow shared access to files, printers, security, applications, and other networking functions over a small private network. One more important aspect of Network Operating Systems is that all the users are well aware of the underlying configuration, of all other users within the network, their individual connections, etc. and that’s why these computers are popularly known as tightly coupled systems. 1st unit of operating system Network Operating System Advantages of Network Operating System  Highly stable centralized servers.  Security concerns are handled through servers.  New technologies and hardware up-gradation are easily integrated into the system.  Server access is possible remotely from different locations and types of systems. Disadvantages of Network Operating System  Servers are costly.  User has to depend on a central location for most operations.  Maintenance and updates are required regularly. Examples of Network Operating Systems are Microsoft Windows Server 2003, Microsoft Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, BSD, etc. 8. Real-Time Operating System These types of OSs serve real-time systems. The time interval required to process and respond to inputs is very small. This time interval is called response time. Real-time systems are used when there are time requirements that are very strict like missile systems, air traffic control systems, robots, etc. Types of Real-Time Operating Systems  Hard Real-Time Systems: Hard Real-Time OSs are meant for applications where time constraints are very strict and even the shortest possible delay is not acceptable. These systems are built for saving life like automatic parachutes or airbags which are required to be readily available in case of an accident. Virtual memory is rarely found in these systems.  Soft Real-Time Systems: These OSs are for applications where time-constraint is less strict. For more, refer to the Difference Between Hard Real-Time OS and Soft Real-Time OS. 1st unit of operating system Real-Time Operating System Advantages of RTOS  Maximum Consumption: Maximum utilization of devices and systems, thus more output from all the resources.  Task Shifting: The time assigned for shifting tasks in these systems is very less. For example, in older systems, it takes about 10 microseconds in shifting from one task to another, and in the latest systems, it takes 3 microseconds.  Focus on Application: Focus on running applications and less importance on applications that are in the queue.  Real-time operating system in the embedded system: Since the size of programs is small, RTOS can also be used in embedded systems like in transport and others.  Error Free: These types of systems are error-free.  Memory Allocation: Memory allocation is best managed in these types of systems. Disadvantages of RTOS  Limited Tasks: Very few tasks run at the same time and their concentration is very less on a few applications to avoid errors.  Use heavy system resources: Sometimes the system resources are not so good and they are expensive as well.  Complex Algorithms: The algorithms are very complex and difficult for the designer to write on.  Device driver and interrupt signals: It needs specific device drivers and interrupts signal to respond earliest to interrupts.  Thread Priority: It is not good to set thread priority as these systems are very less prone to switching tasks. Examples of Real-Time Operating Systems are Scientific experiments, medical imaging systems, industrial control systems, weapon systems, robots, air traffic control systems, etc.  Services of Operating System 1. Program Execution 2. Input Output Operations 3. File Management 4. Error Handling 5. Resource Management 6. Communication between Processes 7. Networking 8. System Utilities 9. User Interface Program Execution 1st unit of operating system It is the Operating System that manages how a program is going to be executed. It loads the program into the memory after which it is executed. The order in which they are executed depends on the CPU Scheduling Algorithms. A few are FCFS, SJF, etc. When the program is in execution, the Operating System also handles deadlock i.e. no two processes come for execution at the same time. The Operating System is responsible for the smooth execution of both user and system programs. The Operating System utilizes various resources available for the efficient running of all types of functionalities. Input Output Operations Operating System manages the input-output operations and establishes communication between the user and device drivers. Device drivers are software that is associated with hardware that is being managed by the OS so that the sync between the devices works properly. It also provides access to input-output devices to a program when needed. File Management The operating system helps in managing files also. If a program needs access to a file, it is the operating system that grants access. These permissions include read-only, read-write, etc. It also provides a platform for the user to create, and delete files. The Operating System is responsible for making decisions regarding the storage of all types of data or files, i.e, floppy disk/hard disk/pen drive, etc. The Operating System decides how the data should be manipulated and stored. Error Handling The Operating System also handles the error occurring in the CPU, in Input-Output devices, etc. It also ensures that an error does not occur frequently and fixes the errors. It also prevents the process from coming to a deadlock. It also looks for any type of error or bugs that can occur while any task. The well-secured OS sometimes also acts as a countermeasure for preventing any sort of breach of the Computer System from any external source and probably handling them. Resource Management System resources are shared between various processes. It is the Operating system that manages resource sharing. It also manages the CPU time among processes using CPU Scheduling Algorithms. It also helps in the memory management of the system. It also controls input-output devices. The OS also ensures the proper use of all the resources available by deciding which resource to be used by whom. Communication between Processes The Operating system manages the communication between processes. Communication between processes includes data transfer among them. If the processes are not on the same computer but connected through a computer network, then also their communication is managed by the Operating System itself. Security In an operating system, protection is a mechanism that controls the access of the process, programs, or users over any resources of the computer system. The operating system ensures that all access to system resources must be monitored and controlled. It also ensures that the 1st unit of operating system external resources or peripherals must be protected from invalid access. It provides authentication by using usernames and passwords. These were some of the services that an operating system provides. Networking This service enables communication between devices on a network, such as connecting to the internet, sending and receiving data packets, and managing network connections. System Utilities These are a set of tools and applications that provide additional functionality to the OS, such as backup and recovery, system optimization, and diagnostic tools. User Interface User interface is essential and all operating systems provide it. Users either interface with the operating system through the command-line interface or graphical user interface or GUI. The command interpreter executes the next user-specified command. A GUI offers the user a mouse-based window and menu system as an interface. Error Management Errors can happen anywhere at any time. A problem could be with the CPU, the I/O, or the memory hardware. The main activities of an operating system with regard to error handling are as follows: 1. The OS continuously scans for potential errors. 2. The OS takes the proper action to guarantee accurate and reliable computing. Resource Administration When working in a multi-user or multi-tasking environment, each user or task should be given its own share of resources like main memory, CPU time, and file storage. The main resource management activities of an operating system are as follows: 1. Schedulers are used by the OS to manage various types of resources. 2. Algorithms for CPU scheduling are employed for increased CPU efficiency. Protection Multiple processes must be shielded from one another’s actions in a computer system with multiple users and concurrent process execution.Protection describes a method or a way to manage how users, processes, or programs can access the resources designated by a computer system. The main protection-related activities of an operating system are as follows: 1. The OS makes sure that all system resources have controlled access. 2. The OS makes sure external I/O devices are secured against unauthorized access attempts. 3. The operating system offers password-based authentication features for each user. 1st unit of operating system What is Kernel in Operating System? In computer science, Kernel is a computer program that is a core or heart of an operating system o As discussed above, Kernel is the core part of an OS(Operating system); hence it has full control over everything in the system. Each operation of hardware and software is managed and administrated by the kernel. o It acts as a bridge between applications and data processing done at the hardware level. It is the central component of an OS. o It is the part of the OS that always resides in computer memory and enables the communication between software and hardware components. o It is the computer program that first loaded on start-up the system (After the bootloader). Once it is loaded, it manages the remaining start-ups. It also manages memory, peripheral, and I/O requests from software. Moreover, it translates all I/O requests into data processing instructions for the CPU. It manages other tasks also such as memory management, task management, and disk management. o A kernel is kept and usually loaded into separate memory space, known as protected Kernel space. It is protected from being accessed by application programs or less important parts of OS. o Other application programs such as browser, word processor, audio & video player use separate memory space known as user-space. o Due to these two separate spaces, user data and kernel data don't interfere with each other and do not cause any instability and slowness. Functions of a Kernel A kernel of an OS is responsible for performing various functions and has control over the system. Some main responsibilities of Kernel are given below: 1) 6device management To perform various actions, processes require access to peripheral devices such as a mouse, keyboard, etc., that are connected to the computer. A kernel is responsible for controlling these 1st unit of operating system devices using device drivers. Here, a device driver is a computer program that helps or enables the OS to communicate with any hardware devices. A kernel maintains a list of all the available devices, and this list may be already known, configured by the user, or detected by OS at runtime. 2) Memory management The kernel has full control for accessing the computer's memory. Each process requires some memory to work, and the kernel enables the processes to safely access the memory. To allocate the memory, the first step is known as virtual addressing, which is done by paging or segmentation. Virtual addressing is a process of providing virtual address spaces to the processes. This prevents the application from crashing into each other. 3) Resource management One of the important functionalities of Kernel is to share the resources between various processes. It must share the resources in a way that each process uniformly accesses the resource. The kernel also provides a way for synchronization and inter-process communication (IPC). It is responsible for context switching between processes. 4) Accessing computer resources 5) A kernel is responsible for accessing computer resources such as RAM and I/O devices. RAM or Random-Access Memory is used to contain both data and instructions. Each program needs to access the memory to execute and mostly wants more memory than the available. For such a case, Kernel plays its role and decides which memory each process will use and what to do if the required memory is not available. The kernel also allocates the request from applications to use I/O devices such as keyboards, microphones, printers, etc. Dual Mode operations in OS An error in one program can adversely affect many processes, it might modify data of another program or also can affect the operating system. For example, if a process stuck in the infinite loop then this infinite loop could affect the correct operation of other processes. So to ensure the proper execution of the operating system, there are two modes of operation: User mode When the computer system is run by user applications like creating a text document or using any application program, then the system is in user mode. When the user application requests for a service from the operating system or an interrupt occurs or system call, then there will be a transition from user to kernel mode to fulfill the requests. Note: To switch from kernel mode to user mode, the mode bit should be 1. Given below image describes what happens when an interruption occurs: Kernel Mode: When the system boots, the hardware starts in kernel mode and when the operating system is loaded, it starts user application in user mode. To provide protection to the hardware, we have privileged instructions which execute only in kernel mode. If the user 1st unit of operating system attempts to run privileged instruction in user mode then it will treat instruction as illegal and traps to OS. Some of the privileged instructions are: 1. Handling Interrupts 2. To switch from user mode to kernel mode. 3. Input-Output management. What is an API? To make you clear with what is an API, let’s take a real-life example of an API, you can think of an API like a waiter in a restaurant who listens to your order request, goes to the chef, takes the food items ordered and gets back to you with the order. Also, if you want to look for the working of an API with the example, here’s one API is an abbreviation for Application Programming Interface which is a collection of communication protocols and subroutines used by various programs to communicate between them. A programmer can make use of various API tools to make their program easier and simpler. Also, an API facilitates programmers with an efficient way to develop their software programs. Thus in simpler terms, an API helps two programs or applications to communicate with each other by providing them with the necessary tools and functions. It takes the request from the user and sends it to the service provider and then again sends the result generated from the service provider to the desired user. System calls in computing, a system call is a programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. A system call is a way for programs to interact with the operating system. A computer program makes a system call when it makes a request to the operating system’s kernel. System call provides the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and an operating system to allow user-level processes to request services of the operating system. System calls are the only entry points into the kernel system. All programs needing resources must use system calls. A user program can interact with the operating system using a system call. A number of services are requested by the program, and the OS responds by launching a number of systems calls to fulfill the request. A system call can be written in high-level languages like C or Pascal or in assembly language. If a high-level language is used, the operating system may directly invoke system calls, which are predefined functions. A system call is a mechanism used by programs to request services from the operating system (OS). In simpler terms, it is a way for a program to interact with the underlying system, such as accessing hardware resources or performing privileged operations. A system call is initiated by the program executing a specific instruction, which triggers a switch to kernel mode, allowing the program to request a service from the OS. The OS then handles the request, performs the necessary operations, and returns the result back to the program. System calls are essential for the proper functioning of an operating system, as they provide a standardized way for programs to access system resources. Without system calls, each program would need to implement its own methods for accessing hardware and system services, leading to inconsistent and error-prone behavior. Features of System Calls 1. Interface: System calls provide a well-defined interface between user programs and the operating system. Programs make requests by calling specific functions, and the operating system responds by executing the requested service and returning a result. 2. Protection: System calls are used to access privileged operations that are not available to normal user programs. The operating system uses this privilege to protect the system from malicious or unauthorized access. 1st unit of operating system 3. Kernel Mode: When a system call is made, the program is temporarily switched from user mode to kernel mode. In kernel mode, the program has access to all system resources, including hardware, memory, and other processes. 4. Context Switching: A system call requires a context switch, which involves saving the state of the current process and switching to the kernel mode to execute the requested service. This can introduce overhead, which can impact system performance. 5. Error Handling: System calls can return error codes to indicate problems with the requested service. Programs must check for these errors and handle them appropriately. 6. Synchronization: System calls can be used to synchronize access to shared resources, such as files or network connections. The operating system provides synchronization mechanisms, such as locks or semaphores, to ensure that multiple programs can access these resources safely. System Calls Advantages 1. Access to hardware resources: System calls allow programs to access hardware resources such as disk drives, printers, and network devices. 2. Memory management: System calls provide a way for programs to allocate and deallocate memory, as well as access memory-mapped hardware devices. 3. Process management: System calls allow programs to create and terminate processes, as well as manage inter-process communication. 4. Security: System calls provide a way for programs to access privileged resources, such as the ability to modify system settings or perform operations that require administrative permissions. 5. Standardization: System calls provide a standardized interface for programs to interact with the operating system, ensuring consistency and compatibility across different hardware platforms and operating system versions. How does System Call Work? The Applications operate in user space, a portion of memory. The operating system’s kernel, which runs in kernel space, is reached through a system call. An application must first request permission from the kernel before it can create a system call. It accomplishes this by sending an interrupt request, which pauses the running process and gives the kernel control. The kernel carries out the requested action, such as creating or deleting a file, if the request is approved. The output of the kernel is provided to the application as input. Once the input is received, the application continues the process. The kernel transfers data from kernel space to user space in memory after the operation is complete and returns the results to the application. Overall, system calls are essential for the proper functioning of an operating system and provide a powerful mechanism for programs to interact with the underlying system in a controlled and secure manner. Features of System Calls 1. Interface: System calls provide a well-defined interface between user programs and the operating system. Programs make requests by calling specific functions, and the operating system responds by executing the requested service and returning a result. 2. Protection: System calls are used to access privileged operations that are not available to normal user programs. The operating system uses this privilege to protect the system from malicious or unauthorized access. 3. Kernel Mode: When a system call is made, the program is temporarily switched from user mode to kernel mode. In kernel mode, the program has access to all system resources, including hardware, memory, and other processes. 4. Context Switching: A system call requires a context switch, which involves saving the state of the current process and switching to the kernel mode to execute the requested service. This can introduce overhead, which can impact system performance. 5. Error Handling: System calls can return error codes to indicate problems with the requested service. Programs must check for these errors and handle them appropriately. 1st unit of operating system 6. Synchronization: System calls can be used to synchronize access to shared resources, such as files or network connections. The operating system provides synchronization mechanisms, such as locks or semaphores, to ensure that multiple programs can access these resources safely. System Calls Advantages 1. Access to hardware resources: System calls allow programs to access hardware resources such as disk drives, printers, and network devices. 2. Memory management: System calls provide a way for programs to allocate and deallocate memory, as well as access memory-mapped hardware devices. 3. Process management: System calls allow programs to create and terminate processes, as well as manage inter-process communication. 4. Security: System calls provide a way for programs to access privileged resources, such as the ability to modify system settings or perform operations that require administrative permissions. 5. Standardization: System calls provide a standardized interface for programs to interact with the operating system, ensuring consistency and compatibility across different hardware platforms and operating system versions. How does System Call Work? The Applications operate in user space, a portion of memory. The operating system’s kernel, which runs in kernel space, is reached through a system call. An application must first request permission from the kernel before it can create a system call. It accomplishes this by sending an interrupt request, which pauses the running process and gives the kernel control. The kernel carries out the requested action, such as creating or deleting a file, if the request is approved. The output of the kernel is provided to the application as input. Once the input is received, the application continues the process. The kernel transfers data from kernel space to user space in memory after the operation is complete and returns the results to the application. Overall, system calls are essential for the proper functioning of an operating system and provide a powerful mechanism for programs to interact with the underlying system in a controlled and secure manner. Services Provided by System Calls 1. Process creation and management 2. Main memory management 3. File Access, Directory, and File system management 4. Device handling(I/O) 5. Protection 6. Networking, etc. Types of system calls 1. Process control: end, abort, create, terminate, allocate, and free memory. 2. File management: create, open, close, delete, read files,s, etc. 3. Device management 4. Information maintenance 5. Communication 1. Process Control The following services are provided by Process Control System calls that are used to control a process.  To forcefully abort the process, simply end it normally.  Execute a process after loading it into the main memory.  Terminate the current process before starting a new one. 1st unit of operating system  Wait for a process to complete running. Wait until a specific event happens, then announce it once it has.  Allocate memory to a process, then release the memory if the process is terminated. 2. File Management The following services are provided by system call for file management:  creat and delete files  Open the file, then close it.  Write to a specific file, read from a specific file.  To obtain a file's attribute and to change a file's attribute 3. Device Management The following services are offered by a system call that controls I/O devices:  Devices might be needed while a process is running. such as access to the file system, I/O devices, main memory, etc.  As a result, it can ask for a device and then release it once the task is complete.  when a requested device is granted access by the process. It is capable of reading, writing, and repositioning operations.  In order to obtain or modify a specific device's attribute.  To detach a device from the processor that is currently executing a command, the call can be made. 4. Information Maintenance The system calls for information maintenance call moves data from the user programme to the operating system. Considering this, the services offered by this type of system call are:  Obtain the system's time or date. Set the system's time or date.  Obtain system-related information. Configure the system data.  Obtain the characteristics of a specific operating system process. Alternatively, of a specific file on the system or on any attached devices.  Set the characteristics of a specific operating system process. Alternatively, of a specific file on the system or on any attached devices. 5. Communication Such a system call facilitates the system's network connection. The services that these system calls offer are:  Open a fresh connection to send the data. After the transmission is finished, disconnect from the connection.  On a particular connection, send a message. Obtain communication from a specific connection.  Identify and connect a specific remote device to the network. Remove a specific remote computer or device from the network. Examples of a System Call in Windows and Unix System calls for Windows and Unix come in many different forms. These are listed in the table below as follows: 1st unit of operating system Process Windows Quiz CreateProcess() Fork() Process Control ExitProcess() Exit() WaitForSingleObject() Wait() Open() CreateFile() File manipulation Read() ReadFile() Write() WriteFile() Close() Device SetConsoleMode() Ioctl() Management ReadConsole() Read() WriteConsole() Write() Information GetCurrentProcessID() Getpid() Maintenance SetTimer() Alarm() Sleep() Sleep() CreatePipe() Pipe() Communication CreateFileMapping() Shmget() MapViewOfFile() Mmap() SetFileSecurity() Chmod() Protection InitializeSecurityDescriptor() Umask() SetSecurityDescriptorgroup() Chown() open(): Accessing a file on a file system is possible with the open() system call. It gives the file resources it needs and a handle the process can use. A file can be opened by multiple processes simultaneously or just one process. Everything is based on the structure and file system. read(): Data from a file on the file system is retrieved using it. In general, it accepts three arguments: 1. A description of a file. 2. A buffer for read data storage. 3. How many bytes should be read from the file Before reading, the file to be read could be identified by its file descriptor and opened using the open() function. wait(): In some systems, a process might need to hold off until another process has finished running before continuing. When a parent process creates a child process, the execution of the parent process is halted until the child process is complete. The parent process is stopped using the wait() system call. The parent process regains control once the child process has finished running. write(): Data from a user buffer is written using it to a device like a file. A program can produce data in one way by using this system call. generally, there are three arguments: 1. A description of a file. 2. A reference to the buffer where data is stored. 3. The amount of data that will be written from the buffer in bytes. fork() The fork() system call is used by processes to create copies of themselves. It is one of the methods used the most frequently in operating systems to create processes. When a parent process creates a child process, the parent process’s execution is suspended until the 1st unit of operating system child process is finished. The parent process regains control once the child process has finished running. fork(): The fork() system call is used by processes to create copies of themselves. It is one of the methods used the most frequently in operating systems to create processes. When a parent process creates a child process, the parent process’s execution is suspended until the child process is finished. The parent process regains control once the child process has finished running. exit(): A system call called exit() is used to terminate a program. In environments with multiple threads, this call indicates that the thread execution is finished. After using the exit() system function, the operating system recovers the resources used by the process. system Programming :- it can be defined as the act of building Systems Software using System Programming Languages. According to Computer Hierarchy, one which comes at last is Hardware. Then it is Operating System, System Programs, and finally Application Programs. Program Development and Execution can be done conveniently in System Programs. Some of the System Programs are simply user interfaces, others are complex. It traditionally lies between the user interface and system calls. So here, the user can only view up-to-the System Programs he can’t see System Calls. System Programs can be divided into these categories : 1. FileManagement – A file is a collection of specific information stored in the memory of a computer system. File management is defined as the process of manipulating files in the computer system, its management includes the process of creating, modifying and deleting files.  It helps to create new files in the computer system and placing them at specific locations.  It helps in easily and quickly locating these files in the computer system.  It makes the process of sharing files among different users very easy and user-friendly.  It helps to store files in separate folders known as directories.  These directories help users to search files quickly or to manage files according to their types of uses.  It helps users to modify the data of files or to modify the name of files in directories. 2. Staus information Information like date, time amount of available memory, or disk space is asked by some users. Others providing detailed performance, logging, and debugging information which is more complex. All this information is formatted and displayed on output devices or printed. Terminal or other output devices or files or a window of GUI is used for showing the output of programs. 1st unit of operating system 3. File-Modification – For modifying the contents of files we use this. For Files stored on disks or other storage devices, we used different types of editors. For searching contents of files or perform transformations of files we use special commands. 4. Programming-Language-support – For common programming languages, we use Compilers, Assemblers, Debuggers, and interpreters which are already provided to users. It provides all support to users. We can run any programming language. All languages of importance are already provided. 5. Program Loading and Execution – When the program is ready after Assembling and compilation, it must be loaded into memory for execution. A loader is part of an operating system that is responsible for loading programs and libraries. It is one of the essential stages for starting a program. Loaders, relocatable loaders, linkage editors, and Overlay loaders are provided by the system. 6. Communications – Virtual connections among processes, users, and computer systems are provided by programs. Users can send messages to another user on their screen, User can send e-mail, browsing on web pages, remote login, the transformation of files from one user to another. Differentiate between application program and system program. System Program The system programs are used to program the operating system software. While application programs provide software that is used directly by the user, system programs provide software that are used by other systems such as SaaS applications, computational science applications etc.  It is the collection of components and art or designing of a given program.  System program aims to produce software which provides services to the computer hardware.  System program that executes the application software. It helps in executing the application software.  These programs allow the application programmer to focus on application to be develop without concerning about the internal details of the System.  Using system programming, a programmer can make assumptions about the hardware of the system that the program runs on.  A low level programming language is used in system programming normally. This is so that the programs can operate in low resource environments easily.  Some parts of the system programs may be directly written in assembly language by the programmers.  A debugger cannot be used on system programs mostly. This problem can be solved by running the programs in a simulated environment.  Examples: Assembler Microprocessor, Loader, Linker, Compiler Application Program:  These are the set of programs that view computer as a tool for solving a particular problem.  Application software is a software that are been used by the end user.  These programs perform a particular function directly for the users. Some of the common application programs include Email, web browsers, gaming software, word processors, graphics software, media player etc.  The requests for service and application communication systems used in an application by a programmer is known as an application program interface (API).  Application programming is used to build application software which includes software like notepad, Word Pad, calculator, web browser, Microsoft excel and many more. 1st unit of operating system  It interacts with system software which in turn interacts and makes physical hardware functional.  Examples: Word Processing, Hotel Management System, Accounting Package etc. Design and Implementation in Operating System:- The design of an operating system is a broad and complex topic that touches on many aspects of computer science. This article will cover the design of operating systems in general and then focus on the implementation aspect. Design Goals: Design goals are the objectives of the operating system. They must be met to fulfill design requirements and they can be used to evaluate the design. These goals may not always be technical, but they often have a direct impact on how users perceive their experience with an operating system. While designers need to identify all design goals and prioritize them, they also need to ensure that these goals are compatible with each other as well as compatible with user expectations or expert advice Designers also need to identify all possible ways in which their designs could conflict with other parts of their systems—and then prioritize those potential conflicts based on cost-benefit analysis (CBA). This process allows for better decision-making about what features make sense for inclusion into final products versus those which would require extensive rework later down the road. It’s also important to note that CBA is not just about financial costs; it can also include other factors like user experience, time to market, and the impact on other systems. The process of identifying design goals, conflicts, and priorities is often referred to as “goal- driven design.” The goal of this approach is to ensure that each design decision is made with the best interest of users and other stakeholders in mind. Mechanisms and Policies: An operating system is a set of software components that manage a computer’s resources and provide overall system management. Mechanisms and policies are the two main components of an operating system. Mechanisms handle low-level functions such as scheduling, memory management, and interrupt handling; policies handle higher-level functions such as resource management, security, and reliability. A well-designed OS should provide both mechanisms and policies for each component in order for it to be successful at its task: Mechanisms should ensure that applications have access to appropriate hardware resources (seats). They should also make sure that applications don’t interfere with each other’s use of these resources (for example through mutual exclusion). Policies determine how processes will interact with one another when they’re running simultaneously on multiple CPUs within a single machine instance – what processor affinity should occur during multitasking operations? Should all processes be allowed access simultaneously or just those belonging specifically within group ‘A’?’ These are just some of the many questions that policies must answer. The OS is responsible for enforcing these mechanisms and policies, as well as handling exceptions when they occur. The operating system also provides a number of services to applications, such as file access and networking capabilities. The operating system is also responsible for making sure that all of these tasks are done efficiently and in a timely manner. The OS provides applications with access to the underlying hardware resources and ensures that they’re properly utilized by the application. It also handles any exceptions that occur during execution so that they don’t cause the entire system to crash. 1st unit of operating system Implementation: Implementation is the process of writing source code in a high-level programming language, compiling it into object code, and then interpreting (executing) this object code by means of an interpreter. The purpose of an operating system is to provide services to users while they run applications on their computers. The main function of an operating system is to control the execution of programs. It also provides services such as memory management, interrupt handling, and file system access facilities so that programs can be better utilized by users or other devices attached to the system. An operating system is a program or software that controls the computer’s hardware and resources. It acts as an intermediary between applications, users, and the computer’s hardware. It manages the activities of all programs running on a computer without any user intervention. The operating system performs many functions such as managing the computer’s memory, enforcing security policies, and controlling peripheral devices. It also provides a user interface that allows users to interact with their computers. The operating system is typically stored in ROM or flash memory so it can be run when the computer is turned on. The first operating systems were designed to control mainframe computers. They were very large and complex, consisting of millions of lines of code and requiring several people to develop them. Today, operating systems are much smaller and easier to use. They have been designed to be modular so they can be customized by users or developers. There are many different types of operating systems: 1. Graphical user interfaces (GUIs) like Microsoft Windows and Mac OS. 2. Command line interfaces like Linux or UNIX 3. Real-time operating systems that control industrial and scientific equipment 4. Embedded operating systems are designed to run on a single computer system without needing an external display or keyboard. an operating system manages resources such as memory, input/output devices, file systems, and other components of a computer system’s hardware architecture (hardware). It does not manage application software or its data; this responsibility resides with individual applications themselves or their respective developers via APIs provided by each application’s interfaces with their respective environments (e.g., Java VM). The design and implementation of an operating system is a complex process that involves many different disciplines. The goal is to provide users with a reliable, efficient, and convenient computing environment, so as to make their work more efficient. Os structure The operating system can be implemented with the help of various structures. The structure of the OS depends mainly on how the various standard components of the operating system are interconnected and melded into the kernel. A design known as an operating system enables user application programs to communicate with the machine’s hardware. Given its complex design and need to be easy to use and modify, the operating system should be constructed with the utmost care. A straightforward way to do this is to supernaturally develop the operating system. These parts must each have unique inputs, outputs, and functionalities. This article discusses a variety of operating system implementation structures, including those listed below, as well as how and why they function. Additionally, the operating system structure is defined. 1st unit of operating system Depending on this, we have the following structures in the operating system: 1. Simple Structure 2. Layered Approach Structure 3. Micro-Kernel Structure 4. Exo-Kernel Structure 5. Virtual Machines Simple structure Such operating systems do not have well-defined structures and are small, simple, and limited. The interfaces and levels of functionality are not well separated. MS-DOS is an example of such an operating system. In MS-DOS, application programs are able to access the basic I/O routines. These types of operating systems cause the entire system to crash if one of the user programs fails. A diagram of the structure of MS-DOS is shown below. Advantages of Simple structure  It delivers better application performance because of the few interfaces between the application program and the hardware.  It is easy for kernel developers to develop such an operating system. Disadvantages of Simple structure  The structure is very complicated, as no clear boundaries exist between modules.  It does not enforce data hiding in the operating system. Layered structure An OS can be broken into pieces and retain much more control over the system. In this structure, the OS is broken into a number of layers (levels). The bottom layer (layer 0) is the hardware, and the topmost layer (layer N) is the user interface. These layers are so designed that each layer uses the functions of the lower-level layers. This simplifies the debugging process, if lower-level layers are debugged and an error occurs during debugging, then the error must be on that layer only, as the lower-level layers have already been debugged. The main disadvantage of this structure is that at each layer, the data needs to be modified and passed on which adds overhead to the system. Moreover, careful planning of the layers is necessary, as a layer can use only lower level layers. UNIX is an example of this structure. 1st unit of operating system Advantages of Layered structure  Layering makes it easier to enhance the operating system, as the implementation of a layer can be changed easily without affecting the other layers.  It is very easy to perform debugging and system verification. Disadvantages of Layered structure  In this structure, the application’s performance is degraded as compared to simple structure.  It requires careful planning for designing the layers, as the higher layers use the functionalities of only the lower layers. Micro-kernel This structure designs the operating system by removing all non-essential components from the kernel and implementing them as system and user programs. This results is in a smaller kernel called the micro-kernel. Advantages of this structure are that all new services need to be added to user space and does not require the kernel to be modified. Thus it is more secure and reliable as if a service fails, then rest of the operating system remains untouched. Mac OS is an example of this type of OS. Advantages of Micro-kernel structure 1. It makes the operating system portable to various platforms. 2. As microkernels are small so these can be tested effectively. Disadvantages of Micro-kernel structure 1. Increased level of inter module communication degrades system performance. EXOKERNEL An operating system called Exokernel was created at MIT with the goal of offering application- level management of hardware resources. The exokernel architecture's goal is to enable application-specific customization by separating resource management from protection. Exokernel size tends to be minimal due to its limited operability. Because the OS sits between the programs and the actual hardware, it will always have an effect on the functionality, performance, and breadth of the apps that are developed on it. By rejecting the idea that an operating system must offer abstractions upon which to base applications, the exokernel operating system makes an effort to solve this issue. The goal is to give developers as few restriction on the use of abstractions as possible while yet allowing them the freedom to do so when necessary. Because of the way the exokernel architecture is designed, a single tiny kernel is responsible for moving all hardware abstractions into unreliable libraries known as library operating systems. Exokernels differ from micro- and monolithic kernels in that their primary objective is to prevent forced abstraction. Exokernel operating systems have a number of features, including: 1st unit of operating system o Enhanced application control support. o Splits management and security apart. o A secure transfer of abstractions is made to an unreliable library operating system. o Brings up a low-level interface. o Operating systems for libraries provide compatibility and portability. Advantages of Exokernel Structure: o Application performance is enhanced by it. o Accurate resource allocation and revocation enable more effective utilisation of hardware resources. o New operating systems can be tested and developed more easily. o Every user-space program is permitted to utilise its own customised memory management. Disadvantages of Exokernel Structure: o A decline in consistency o Exokernel interfaces have a complex architecture. Modular structure or approach It is considered as the best approach for an OS. It involves designing of a modular kernel. The kernel has only a set of core components and other services are added as dynamically loadable modules to the kernel either during runtime or boot time. It resembles layered structure due to the fact that each kernel has defined and protected interfaces, but it is more flexible than a layered structure as a module can call any other module. For example Solaris OS is organized as shown in the figure. VIRTUAL MACHINES (VMs) The hardware of our personal computer, including the CPU, disc drives, RAM, and NIC (Network Interface Card), is abstracted by a virtual machine into a variety of various execution contexts based on our needs, giving us the impression that each execution environment is a separate computer. A virtual box is an example of it. Using CPU scheduling and virtual memory techniques, an operating system allows us to execute multiple processes simultaneously while giving the impression that each one is using a separate processor and virtual memory. System calls and a file system are examples of extra functionalities that a process can have that the hardware is unable to give. Instead of offering 1st unit of operating system these extra features, the virtual machine method just offers an interface that is similar to that of the most fundamental hardware. A virtual duplicate of the computer system underneath is made available to each process. We can develop a virtual machine for a variety of reasons, all of which are fundamentally connected to the capacity to share the same underlying hardware while concurrently supporting various execution environments, i.e., various operating systems. Disk systems are the fundamental problem with the virtual machine technique. If the actual machine only has three-disc drives but needs to host seven virtual machines, let's imagine that. It is obvious that it is impossible to assign a disc drive to every virtual machine because the program that creates virtual machines would require a sizable amount of disc space in order to offer virtual memory and spooling. The provision of virtual discs is the solution. The result is that users get their own virtual machines. They can then use any of the operating systems or software programs that are installed on the machine below. Virtual machine software is concerned with programming numerous virtual machines simultaneously into a physical machine; it is not required to take into account any user-support software. With this configuration, it may be possible to break the challenge of building an interactive system for several users into two manageable chunks. Advantages of Virtual Machines: o Due to total isolation between each virtual machine and every other virtual machine, there are no issues with security. o A virtual machine may offer an architecture for the instruction set that is different from that of actual computers. o Simple availability, accessibility, and recovery convenience. Disadvantages of Virtual Machines: o Depending on the workload, operating numerous virtual machines simultaneously on a host computer may have an adverse effect on one of them. o When it comes to hardware access, virtual computers are less effective than physical ones.

Use Quizgecko on...
Browser
Browser