Operating System Services: A Comprehensive Overview, Study notes of Operating Systems

Notes decsribe the services provided by operating system

Typology: Study notes

2021/2022

Uploaded on 06/03/2022

rukshana-aly
rukshana-aly 🇱🇰

4

(1)

7 documents

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 2: Operating System Services
1. What is User Interface (UI)?
User Interface (UI) is anything a user may interact with to use a digital product or service.
There are four prevalent types of user interface and each has a range of advantages and
disadvantages:
Command Line Interface (CLI).
Menu-driven Interface.
Graphical User Interface (GUI).
Touchscreen Graphical User Interface.
CLI is a command line program that accepts text input to execute operating system
functions.
Other Names for a Command Line Interpreter
Any command line interpreter program is also often referred to in general as a command
line interface. Less commonly, it's also called a CLI, command language interpreter, console
user interface, command processor, shell, command line shell, or a command interpreter.
A GUI (graphical user interface) is a system of interactive visual components for computer
software.
A touchscreen GUI is a graphical user interface operated by fingertips or a stylus.
Batch interfaces are non-interactive user interfaces, where the user specifies all the
details of the batch job in advance to batch processing and receives the output when all the
processing is done.
Following are the common services provided by an operating system:
Program execution
I/O operations
File system manipulation
Communication
Error detection
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Operating System Services: A Comprehensive Overview and more Study notes Operating Systems in PDF only on Docsity!

Lecture 2: Operating System Services

  1. What is User Interface (UI)? User Interface (UI) is anything a user may interact with to use a digital product or service. There are four prevalent types of user interface and each has a range of advantages and disadvantages:  Command Line Interface (CLI).  Menu-driven Interface.  Graphical User Interface (GUI).  Touchscreen Graphical User Interface. CLI is a command line program that accepts text input to execute operating system functions. Other Names for a Command Line Interpreter Any command line interpreter program is also often referred to in general as a command line interface. Less commonly, it's also called a CLI, command language interpreter, console user interface, command processor, shell, command line shell, or a command interpreter. A GUI (graphical user interface) is a system of interactive visual components for computer software. A touchscreen GUI is a graphical user interface operated by fingertips or a stylus. Batch interfaces are non-interactive user interfaces, where the user specifies all the details of the batch job in advance to batch processing and receives the output when all the processing is done. Following are the common services provided by an operating system:  Program execution  I/O operations  File system manipulation  Communication  Error detection

 Resource allocation  Protection

  1. Program Execution An operating system must be able to load many kinds of activities into the memory and to run it. The program must be able to end its execution, either normally or abnormally. A process includes the complete execution of the written program or code. There are some of the activities which are performed by the operating system:  The operating system Loads program into memory  It also Executes the program  It Handles the program’s execution  It Provides a mechanism for process synchronization  It Provides a mechanism for process communication
  2. I/O Operations The communication between the user and devices drivers are managed by the operating system. I/O devices are required for any running process. In I/O a file or an I/O devices can be involved. I/O operations are the read or write operations which are done with the help of input-output devices. Operating system give the access to the I/O devices when it required.
  3. File system manipulation The collection of related information which represent some content is known as a file. The computer can store files on the secondary storage devices. For long-term storage purpose. examples of storage media include magnetic tape, magnetic disk and optical disk drives like CD, DVD. A file system is a collection of directories for easy understand and usage. These directories contain some files. There are some major activities which are performed by an operating system with respect to file management. The operating system gives an access to the program for performing an operation on the file. Programs need to read and write a file. The user can create/delete a file by using an interface provided by the operating system. The operating system provides an interface to the user creates/ delete directories. The backup of the file system can be created by using an interface provided by the operating system.

Simply put, the shell is a program that takes commands from the keyboard and gives them to the operating system to perform. In the old days, it was the only user interface available on a Unix-like system such as Linux. Nowadays, we have graphical user interfaces (GUIs) in addition to command line interfaces (CLIs) such as the shell. On most Linux systems a program called bash (which stands for Bourne Again Shell, an enhanced version of the original Unix shell program, sh, written by Steve Bourne) acts as the shell program. Besides bash, there are other shell programs available for Linux systems. These include: ksh, tcsh and zsh. Bourne Shell Command Interpreter The Bourne shell is an interactive command interpreter and command programming language. The bsh command runs the Bourne shell. What is Xerox PARC famous for? 1973: Superpaint frame buffer. Xerox PARC computer scientists record the first video image on the first computer paint system – a graphics program and framebuffer computer. This paves the way for the earliest computer animations and later earns its inventors an Emmy and an Academy Award. Introduction to System Call 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 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. 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 : There are 5 different categories of system calls –  Process control: end, abort, create, terminate, allocate and free memory.  File management: create, open, close, delete, read file etc.

 Device management  Information maintenance  Communication  Protection Examples of Windows and Unix System Calls – Why do we use an API rather than direct system call in the OS?

Why you need API rather than direct system calls in an OS is because

… of the following benefits such as.

 Portability : Any program using that API can compile and run ,as

long as the system/program supports the API.

 Ease of Use compared to actual system call

surroundings or the Third party API’s, for which we have to get the codes from other sites on the web(e.g. Facebook, Twitter). Types of APIs: There are three basic forms of API- WEB APIs: A Web API also called as Web Services is an extensively used API over the web and can be easily accessed using the HTTP protocols. A Web API is an open source interface and can be used by a large number of clients through their phones, tablets. or PC’s. LOCAL APIs: In this types of API, the programmers get the local middleware services. TAPI (Telephony Application Programming Interface), .NET are common examples of Local API’s. PROGRAM APIs: It makes a remote program appears to be local by making use of RPC’s (Remote Procedural Calls). SOAP is a well-known example of this type of API. Few other types of APIs:  SOAP (SIMPLE OBJECT ACCESS PROTOCOL): It defines messages in XML format used by web applications to communicate with each other.  REST (Representational State Transfer): It makes use of HTTP to GET, POST, PUT, or DELETE data. It is basically used to take advantage of the existing data.  JSON-RPC: It use JSON for data transfer and is a light-weight remote procedural call defining few data structure types.  XML-RPC: It is based on XML and uses HTTP for data transfer. This API is widely used to exchange information between two or more networks. Above are the various types and forms of API’s extensively used over web networks to exchange information and to enhance communication between them.

Advantages of APIs –  Efficiency: API produces efficient, quicker and more reliable results than the outputs produced by human beings in an organization.  Flexible delivery of services: API provides fast and flexible delivery of services according to developers requirements.  Integration: The best feature of API is that it allows movement of data between various sites and thus enhances integrated user experience.  Automation: As API makes use of robotic computers rather than humans, it produces better and automated results.  New functionality: While using API the developers find new tools and functionality for API exchanges. Disadvantages of APIs –  Cost: Developing and implementing API is costly at times and requires high maintenance and support from developers.  Security issues: Using API adds another layer of surface which is then prone to attacks, and hence the security risk problem is common in API’s. SYSTEM CALL from tutorialpoint.com System calls are usually made when a process in user mode requires access to a resource. Then it requests the kernel to provide the resource via a system call. A figure representing the execution of the system call is given as follows − As can be seen from this diagram, the processes execute normally in the user mode until a system call interrupts this. Then the system call is executed on a priority basis in the kernel

file. A file can be opened by multiple processes at the same time or be restricted to one process. It all depends on the file organisation and file system. read() The read() system call is used to access data from a file that is stored in the file system. The file to read can be identified by its file descriptor and it should be opened using open() before it can be read. In general, the read() system calls takes three arguments i.e. the file descriptor, buffer which stores read data and number of bytes to be read from the file. write() The write() system calls writes the data from a user buffer into a device such as a file. This system call is one of the ways to output data from a program. In general, the write system calls takes three arguments i.e. file descriptor, pointer to the buffer where data is stored and number of bytes to write from the buffer. close() The close() system call is used to terminate access to a file system. Using this system call means that the file is no longer required by the program and so the buffers are flushed, the file metadata is updated and the file resources are de-allocated. https://www.tutorialspoint.com/what-are-system-calls-in-operating-system What does POSIX stand for? Portable Operating System Interface POSIX (Portable Operating System Interface) is a set of standard operating system interfaces based on the Unix operating system. Unistd.h In the C and C++ programming languages, unistd.h is the name of the header file that provides access to the POSIX operating system API. A system call is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. Through a system call the programs interact with the operating system. Often some additional information is required when a system call is executed. The exact type and amount of information might vary according to the particular operating system and the particular system call. This additional information that we pass is nothing more than a variable and we name it a parameter. For example to get input, we may need to specify the file from which we need to read. Parameters in this

context generally are passed to system calls in the same way that parameters are passed to other functions in programming. There are three ways to pass parameters:

  1. Registers The first method is to pass the parameters in registers. Parameter passing is easy if the parameters are passed in registers as this is the most direct way to pass parameters.
  2. Block When there may be more parameters than registers the parameters are generally stored in a block or table in memory and the address of the block is passed as a parameter in a register. So in this case the passed parameter to the registers will be the addresses of block of parameters.
  3. Stack Parameters also can be place or pushed onto a stack by the program and popped off the stack by the operating system. Since this method does not limit the number or length of parameters it is preferred from some OS. Linker A linker is special program that combines the object files, generated by compiler/assembler, and other pieces of codes to originate an executable file have. exe extension. In the object file, linker searches and append all libraries needed for execution of file. It regulates the memory space that will hold the code from each module. It also merges two or more separate object programs and establishes link among them. Generally, linkers are of two types :
  4. Linkage Editor
  5. Dynamic Linker An illustration of the linking process. Object files and static libraries are assembled into a new library or executable Loader The loader is special program that takes input of executable files from linker, loads it to main memory, and prepares this code for execution by computer. Loader Function : The loader performs the following functions : ■ Allocation - The loader determines and allocates the required memory space for the program to execute properly.

Static links. These are linked earlier in the process and are embedded into the executable. Static libraries are linked to the executable when the program is compiled. Dynamic libraries are linked later, either at runtime or at load time. Static libraries are not shared between programs because they are written into the individual executable. Dynamic links. DLLs contain the files that a program links to. The libraries already are stored on the computer, external to the program that the user writes. They are called dynamic because they are not embedded in the executable -- they just link to it when needed. An import library, which is a type of static library, replaces all placeholder symbols with actual links to the necessary DLL data in the main program at load time, pulling those functions from the DLL library. Programs provide the name of the library, and the OS creates a path to the link library. Different programs have their own language-specific calling conventions for linking to DLLs. Because dynamic libraries are not written into the executable, the same shared library can be used by more than one program at the same time. They can also be modified without changing the entire program that is using it.

Operating System Structures

Operating system can be implemented with the help of various structures. The structure of the OS depends mainly on how the various common components of the operating system are interconnected and melded into the kernel. Depending on this we have following structures of the operating system: Simple structure: Such operating systems do not have well defined structure and are small, simple and limited systems. The interfaces and levels of functionality are not well separated. MS-DOS is an example of such operating system. In MS-DOS application programs are able to access the

basic I/O routines. These types of operating system cause the entire system to crash if one of the user programs fails. 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.  Easy for kernel developers to develop such an operating system. Disadvantages of Simple structure:  The structure is very complicated as no clear boundaries exists 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 on system. In this structure the OS is broken into 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 only. This simplifies the debugging process as 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.

It is considered as the best approach for an OS. It involves designing of a modular kernel. The kernel has only set of core components and other services are added as dynamically loadable modules to the kernel either during run time 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 the layered structure as a module can call any other module. For example Solaris OS is organized as shown in the figure. Microkernel in Operating Systems Difficulty Level : Medium Last Updated : 10 Feb, 2022 Kernel is the core part of an operating system that manages system resources. It also acts as a bridge between the application and hardware of the computer. It is one of the first programs loaded on start-up (after the Bootloader).

Kernel mode and User mode of CPU operation The CPU can execute certain instructions only when it is in kernel mode. These instructions are called privilege instruction. They allow the implementation of special operations whose execution by the user program could interface with the functioning of the operating system or activity of another user program. For example, instruction for managing memory protection.  The operating system puts the CPU in kernel mode when it is executing in the kernel so, that kernel can execute some special operation.  The operating system puts the CPU in user mode when a user program is in execution so, that the user program cannot interface with the operating system program.  User-level instruction does not require special privilege. Example are ADD,PUSH,etc. The concept of modes can be extended beyond two, requiring more than a single mode bit CPUs that support virtualization use one of these extra bits to indicate when the virtual machine manager, VMM, is in control of the system. The VMM has more privileges than ordinary user programs, but not so many as the full kernel. System calls are typically implemented in the form of software interrupts, which causes the hardware’s interrupt handler to transfer control over to an appropriate interrupt handler, which is part of the operating system, switching the mode bit to kernel mode in the process. The interrupt handler checks exactly which interrupt was generated, checks additional parameters ( generally passed through registers ) if appropriate, and then calls the appropriate kernel service routine to handle the service requested by the system call. User programs’ attempts to execute illegal instructions ( privileged or non-existent instructions ), or to access forbidden memory areas, also generate software interrupts, which are trapped by the interrupt handler, and control is transferred to the OS, which issues an appropriate error message, possibly dumps data to a log ( core ) file for later analysis, and then terminates the offending program.

Advantages of Microkernel –  The architecture of this kernel is small and isolated hence it can function better.  Expansion of the system is easier, it is simply added to the system application without disturbing the kernel. Linus Loadable Kernel Module If you want to add code to a Linux kit, the basic way to do that is to add source files to the kernel source tree and assemble the kernel. In fact, the process of setting up the kernel consists mainly to select which files to upload to the kernel will be merged. But you can also add code to the Linux kit while it is running. A piece of code you add this way is called a loadable kernel module (LKM). These modules can do many things, but they are usually one of three items:  device drivers  file system drivers  system calls. Quiz on Operating System Services

  1. What are the services operating System provides to both the users and to the programs? A. File System manipulation B. Error Detection C. Program execution D. Resource Allocation View Answer Ans : C Explanation: An Operating System provides services to both the users and to the programs. It provides programs an environment to execute and It provides users the services to execute the programs in a convenient manner.
  2. Which of the following few common services provided by an operating system? A. Protection B. Program execution C. I/O operations D. All of the above

View Answer Ans : D Explanation: All of the above are services provided by an operating system.

  1. Which of the following are examples of storage media? A. magnetic disk B. optical disk C. Both A and B D. None of the above View Answer Ans : C Explanation: Examples of storage media include magnetic tape, magnetic disk and optical disk drives like CD, DVD.
  2. Which of the following is true about Program execution? A. Restrict to load a program into memory. B. Provides a mechanism for process synchronization. C. Do not provides a mechanism for process communication. D. Do not provides a mechanism for deadlock handling. View Answer Ans : B Explanation: Option B is correct.
  3. Which of the following is false about I/O Operation? A. Operating system does not provides the access to the I/O device B. I/O operation means read or write operation C. An I/O subsystem comprises of I/O devices D. None of the above View Answer Ans : A Explanation: Operating system provides the access to the required I/O device when required.
  4. Which of the following is false about File system manipulation?