Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2:Operating System Structures

Similar presentations


Presentation on theme: "Chapter 2:Operating System Structures"— Presentation transcript:

1 Chapter 2:Operating System Structures
Book: Operating System Principles , 7th Edition , Abraham Silberschatz, Peter Baer Galvin, Greg Gagne

2 Operating System Services
Operating System provides certain services to programs or to the users of those programs Provide for the convenience of programmer to make programming task easier User interface: Almost all operating systems have a user interface (UI) 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 involve a file or an I/O device. Operating system provides a means for I/O

3 Contd… File-system manipulation :The file system is of particular interest. Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management(allow or deny access of file) Communications : Processes may exchange information, on the same computer or between computers over a network Communications may be via shared memory or through message passing

4 Contd… Error detection : OS needs to be constantly aware of possible errors May occur in the CPU and memory hardware (memory error or power failure), in I/O devices (parity error, connection failure on the network, lack of paper in printer), in user program (arithmetic overflow, too great use of CPU time) For each type of error, OS should take the appropriate action to ensure correct and consistent computing Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system

5 Operating System Services
These sets of operating system functions exists to ensure the efficient operation of the system itself Resource allocation: When multiple users or multiple jobs running concurrently, resources must be allocated to each of them Many types of resources - Some (such as CPU cycles, main memory, and file storage) may have special allocation code, others (such as I/O devices) may have general request and release code. CPU scheduling routine that take into account : speed of CPU, jobs that must be executed, number of registers available and other factors Accounting: To keep track of which users use how much and what kinds of computer resources Valuable for researchers who wish to reconfigure the system to improve computing services

6 Contd… 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 Protection involves ensuring that all access to system resources is controlled Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts

7 User Operating System Interface
Two approaches Command Interpreter: allow users to enter commands that are to be performed by the operating system Graphical User Interface: allows the user to interface with the operating system

8 Command Interpreter CLI allows direct command entry
Sometimes implemented in kernel, sometimes by systems program Sometimes multiple flavors implemented :shells . for example C Shell Primarily fetches a command from user and executes it Sometimes commands built-in in command interpreter, sometimes just names of programs (system program, just execute the file) If the latter, adding new features doesn’t require shell modification

9 Graphical User Interface
Provides mouse based system and menu system as an interface 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)

10 System Calls Provides an interface to the services made available by the operating system Generally available as routines written in C and C++ System execute thousands of system calls per second Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use API specifies a set of functions that are available to the application programmer, including the parameters that are passed to each function Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM)

11 Contd… The function that make up the API typically invoke the actual system call on behalf of application programmer Win32 function CreateProcess() actually calls the NTCreateProcess() system call in the windows kernel API preference over system call Portability Simplicity: Actual system call can often be more detailed and difficult to work with than API

12 Example of System Calls

13 Example of Standard API
Consider the ReadFile() function in the Win32 API—a function for reading from a file A description of the parameters passed to ReadFile() HANDLE file—the file to be read LPVOID buffer—a buffer where the data will be read into and written from DWORD bytesToRead—the number of bytes to be read into the buffer LPDWORD bytesRead—the number of bytes read during the last read LPOVERLAPPED ovl—indicates if overlapped I/O is being used

14 System Call Implementation
Typically, a number associated with each system call System-call interface maintains a table indexed according to these numbers The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values The caller need know nothing about how the system call is implemented Just needs to obey API and understand what OS will do as a result call Most details of OS interface hidden from programmer by API Managed by run-time support library (set of functions built into libraries included with compiler)

15 API – System Call – OS Relationship

16 System Call Parameter Passing
Often, more information is required than simply identity of desired system call Exact type and amount of information vary according to OS and call Three general methods used to pass parameters to the OS Simplest: pass the parameters in registers In some cases, may be more parameters than registers Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register This approach taken by Linux and Solaris Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system Block and stack methods do not limit the number or length of parameters being passed

17 Parameters Passing Via Table

18 Types of System Call Divided into five main categories:
Process Control File Manipulation Device Manipulation Information Maintenance Control

19 Process Control System calls to end and abort the system call
A program or process executing one command may load and execute another program Create and delete process Process wait to for a certain amount of time to pass, when created new jobs or processes (wait time) Specific event to occur (wait event)

20 MS-DOS Execution

21 File Management System calls to create, delete, open , read, write, reposition, close the files Either system call requires name of the file and file attributes(file name, file type, protection code, accounting information and so on) Same set of operations for directories if there is a directory structure for organizing files

22 Device Management Various resources controlled by the operating system can be thought of as devices(physical, abstract or virtual devices) System may require to first request the device, if there are multiple users of the system, and after finishing the request, release it Once the device has been requested, we can read, write and reposition the device, just as with files Many operating system merge the two into a combined device- file structure

23 Information Maintenance
Simply for the purpose of transferring information between the user program and the operating system System call to return date and time System call to return information about the system (number of current users, version of operating system, amount of free memory on disk space and so on) System call is used to access the information from the operating system, which keeps information about all its processes

24 Communication Two common models of Interprocess communication
Message Passing Model Easy to implement Useful to transfer small amount of data for intercomputer communication Shared Memory Model Allows maximum speed Problem: area of protection, synchronization between processes sharing memory

25 Message Passing Model The information sent to the specific system call
Exchange messages to transfer information between two processes Messages exchanged either directly or indirectly through the common mailbox For communication, connection must be opened Following information is required for communication Hostid, processid The information sent to the specific system call The receiver accept the information Source: client, Receiver: server Then terminate the connection

26 Shared Memory Model System call to gain and create access of the memory region shared by other processes Two or more processes agree to remove the restriction to share memory in order to exchange information by reading and writing data in the shared areas Form of data and location determined by the processes, not under the operating system control Processes are also responsible for ensuring that they are not writing data in the same location simultaneously


Download ppt "Chapter 2:Operating System Structures"

Similar presentations


Ads by Google