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

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

3 Objectives To describe the services an operating system provides to users, processes, and other systems To discuss the various ways of structuring an operating system To explain how operating systems are installed and customized and how they boot

4 Operating System Services
Operating systems provide an environment for execution of programs and services to programs and users One set of operating-system services provides functions that are helpful to the user: User interface - Almost all operating systems have a user interface (UI). Varies between Command-Line (CLI), Graphics User Interface (GUI), 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

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

6 Operating System Services (Cont.)
Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of them Many types of resources - CPU cycles, main memory, file storage, I/O devices. Accounting - To keep track of which users use how much and what kinds of computer resources Protection and security - The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other 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 - CLI
CLI or command interpreter allows direct command entry Sometimes implemented in kernel, sometimes by systems program On systems with multiple command interpreters to choose from, the interpreters are known as shells. The main function of the command interpreter is to get and execute the next user-specified command. Many of the commands given at this level manipulate files: create, delete, list, print, copy, execute, and so on.

8 Bourne Shell Command Interpreter (used on Solaris 10)

9 User Operating System Interface - GUI
User-friendly desktop interface Usually mouse, keyboard, and monitor. Icons represent files, programs, actions, etc. Many systems now include both CLI and GUI interfaces Microsoft Windows is GUI with CLI “command” shell

10 Touchscreen Interfaces
Touchscreen devices require new interfaces Mouse not possible or not desired Actions and selection based on gestures(double tap, scrolls , long presses) Virtual keyboard for text entry Voice commands.

11 The Mac OS X GUI

12 System Calls System calls provide an interface to the services made available by an operating system. These calls are generally available as routines Typically written in a high-level language (C or C++) or assembly. Typically, application developers design programs according to an application programming interface (API). The API specifies a set of functions that are available to an application programmer, including the parameters that are passed to each function and the return values the programmer can expect. 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)

13 Example of System Calls
System call sequence to copy the contents of one file to another file Note that the system-call names used throughout this text are generic

14 System Call and API Behind the scenes, the functions that make up an API typically invoke the actual system calls on behalf of the application programmer. For example, the Windows function CreateProcess() actually invokes the NTCreateProcess() system call in the Windows kernel. Why would an application programmer prefer programming according to an API rather than invoking actual system calls? If we designing a program using an API we expect that program to compile and run on any system that supports the same API. actual system calls can often be more detailed and difficult to work with than the API available to an application programmer.

15 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 the 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 Know API and understand what OS will do as a result call Most details of OS interface hidden from programmer by API For most programming languages, the run-time support system (a set of functions built into libraries included with a compiler) provides a system call interface that serves as the link to system calls made available by the operating system.

16 API – System Call – OS Relationship

17 Types of System Calls Process control
create process, terminate process end, abort: halt its execution either normally (end) or abnormally (abort). load, execute get process attributes, set process attributes wait for time: Process may needs to wait for another to finish. wait event, signal event: Process may wait for event or signal an event to another. allocate and free memory Dump memory if error Debugger: for determining bugs, single step execution Locks: to lock shared data for managing access to shared data between processes.

18 Types of System Calls File management create file, delete file
open, close file read, write get and set file attributes Device management request device, release device get device attributes, set device attributes

19 Types of System Calls (Cont.)
Information maintenance get system data, set system data For example, most systems have a system call to return the current time() and date(). get and set process, file, or device attributes For example, calls are also used to reset the process information (get process attributes() and set process attributes(). Communications create, delete communication connection between the processes send, receive messages from process to another transfer status information (process ID, process Name,…) Devices Protection Control access to resources Get and set permissions Allow and deny user access

20 Examples of Windows and Unix System Calls

21 Standard C Library Example
C program invoking printf() library call, which calls write() system call

22 System Programs logical computer hierarchy: At the lowest level is hardware. Next is the operating system, then the system programs, and finally the application programs System programs, also known as system utilities, provide a convenient environment for program development and execution. Some of them are simply user interfaces to system calls. Others are considerably more complex

23 System Programs Categories
System Programs can be divided into these categories: File management - These programs Create, delete, copy, rename, print, list, and generally manipulate files and directories Status information Some programs simply ask the system for the date, time, amount of available memory or disk space, number of users, or similar status information. Others are more complex, providing detailed performance, logging, and debugging information File modification. Several text editors may be available to create and modify the content of files, also may be search contents of files or perform transformations of the text. Programming-language support - Compilers, assemblers, debuggers and interpreters sometimes provided for common programming languages. provided with the operating system or available as a separate download

24 System Programs (Cont.)
Program loading and execution- Once a program is assembled or compiled, it must be loaded into memory to be executed. The system may provide loader and Debugging systems for either higher-level languages or machine Communications. These programs provide the mechanism for creating virtual connections among processes, users, and computer systems. Background services. All general-purpose systems have methods for launching certain system-program processes at boot time. Some of these processes terminate after completing their tasks, while others continue to run until the system is halted.

25 Operating System Design and Implementation
Internal structure of different Operating Systems can vary widely Start the design by defining goals and specifications Affected by choice of hardware, type of system User goals and System goals User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient

26 Implementation Much variation Early OSes in assembly language
Then system programming languages like Algol, PL/1 Now C, C++ Actually, an operating system can be written in more than one language The lowest levels of the kernel might be assembly language Higher-level routines might be in C Systems programs might be in C, C++

27 Operating-System Debugging
Debugging is the activity of finding and fixing errors in a system, both in hardware and in software. Performance problems are considered bugs, so debugging can also include performance tuning. If a process fails, most operating systems write the error information to a log file to alert system operators or users that the problem occurred. The operating system can also take a core dump—a capture of the memory of the process— and store it in a file for later analysis. (Memory was referred to as the “core” in the early days of computing.) Running programs and core dumps can be used by a debugger, which allows a programmer to explore the code and memory of a process. A failure in the kernel is called a crash. When a crash occurs, error information is saved to a log file, and the memory state is saved to a crash dump.

28 Operating-System Debugging(cont.)
Performance Tuning performance tuning seeks to improve performance by removing processing bottlenecks. To identify bottlenecks, we must be able to monitor system performance. In a number of systems, All interesting events are logged with their time and important parameters and are written to a file. Later, an analysis program can process the log file to determine system performance and to identify bottlenecks and inefficiencies. Another approach to performance tuning uses single-purpose, interactive tools that allow users and administrators to question the state of various system components to look for bottlenecks. The Windows Task Manager includes information for current applications as well as processes, CPU and memory usage, and networking statistics Kernighan’s Law: “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”

29 Performance Tuning Improve performance by removing bottlenecks
OS must provide means of computing and displaying measures of system behavior For example, “top” program or Windows Task Manager

30 End of Chapter 2


Download ppt "Chapter 2: Operating-System Structures"

Similar presentations


Ads by Google