Document Details

FairOrchid

Uploaded by FairOrchid

KTH Royal Institute of Technology

Tags

system calls operating systems computer science programming

Full Transcript

System Calls Ivy Peng, Stefano Markidis KTH Royal Institute of Technology 1 Operating System Structure 2 System Calls Programming interface Typically written in a to the services provided high-leve...

System Calls Ivy Peng, Stefano Markidis KTH Royal Institute of Technology 1 Operating System Structure 2 System Calls Programming interface Typically written in a to the services provided high-level language (C or by the OS. C++). Mostly accessed by Interface (API) rather programs via a high-level than direct system call Application use. Programming 3 Application Programming Interface (API) The API specifies a set of functions that are available to an application programmer. It includes the parameters that are passed to each function and the return values the programmer can expect. The three most common APIs: POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X) Windows API for Windows Java API for the Java virtual machine (JVM) 4 API and System Calls Why would an application programmer prefer programming according to an API rather than invoking actual system calls? 5 API and System Calls 6 API and System Calls 7 API and System Calls 8 Types of System Calls System calls can be grouped roughly into six major categories: 1. Process control 2. File manipulation 3. Device manipulation 4. Information Maintenance 5. Communications 6. Protection 9 Types of System Calls 10 Kernel Space Ivy Peng, Stefano Markidis KTH Royal Institute of Technology 1 Operating System Structure 2 Splitting the Kernel The kernel’s role can be split into the following parts Process management Memory management Storage management and File system Device control and I/O subsystem Protection and security 3 Process Management A process is a program in execution. The program is a passive entity, and the process is an active entity. A process needs resources to accomplish its task. CPU, memory, I/O, files, initialization data,... Process termination requires the reclaim of any reusable resources. 4 Process Management Activities Process management activities: Scheduling processes and threads on the CPUs. Creating and deleting both user and system processes. Suspending and resuming processes. Providing mechanisms for process synchronization. Providing mechanisms for process communication. 5 Memory Management To execute a program, all (or part) of the instructions must be in memory. All (or part) of the data needed by the program must be in memory. Memory management determines what is in memory and when. Optimizing CPU utilization and computer response to users. 6 Memory Management Activities Keeping track of which parts of memory are currently being used and by whom. Deciding which processes (or parts of) and data to move into and out of memory. Allocating and deallocating memory space as needed. 7 Storage Management Disks are usually used to store data that does not fit in main memory or data that must be kept for a long period of time. Disk management activities: Free-space management Storage allocation Disk scheduling 8 Storage Management II OS provides a uniform and logical view of information storage. OS abstracts physical properties A file is a collection of related information (programs or data). to the logical storage unit called Files are usually organized into a file. directories. OS maps files onto physical media and accesses these files via the storage devices, e.g., disk drive, tape drive. 9 File Management Activities Creating and deleting Primitives to manipulate files and directories. files and directories. Backup files onto stable Mapping files onto (non-volatile) storage secondary storage. media. 10 I/O Subsystem One purpose of OS is to hide details of hardware devices from the user. General device-driver interface. The I/O subsystem consists of Drivers for specific hardware devices. several components: Memory management of I/O. 11 Protection and Security Protection: any mechanism for controlling access of processes or users to resources defined by the OS. Security: defense of the system against internal and external attacks. E.g., denial-of-service, worms, viruses, identity theft, theft of service,... 12 User Space Ivy Peng, Stefano Markidis KTH Royal Institute of Technology 6 Programs Kernel: the program running at all times on a computer. Everything else is either: a system program an application program 7 System Programs An environment for program development and execution. System programs include: File manipulation, e.g., copy, delete, rename, and edit files Status information, e.g., date, time, and available memory Programming language support, e.g., assemblers and debuggers Program loading and execution, e.g., loaders Communications, e.g., services to make connections among processes, users, and hardware Background services, e.g., services and daemons 8 Application Programs Don’t pertain to the system. Run by users. Not typically considered part of OS. Launched by command line, mouse click, finger poke. Web browsers, word processors, database systems, compilers, games,... 9 Operating System Structure Ivy Peng, Stefano Markidis KTH Royal Institute of Technology 1 OS and User Programs The OS and the users share the hardware and software resources of the computer system. We need to ensure that an error in a user program affects only E.g., getting stuck in an infinite loop the one program running. 2 Dual-Mode Operation The dual-mode operation allows the OS to protect itself and other system components. User mode and kernel mode. The system call changes mode to the kernel, and the return from the call resets it to the user. The transition from user to kernel mode 3 Operating System Structure 4 Computer-System Operation Ivy Peng, Stefano Markidis KTH Royal Institute of Technology 1 Computer-System Operation One or more CPUs and device controllers connect through a common bus, providing access to shared memory. The CPU and the device controllers can execute in parallel, competing for memory cycles. Device controllers inform the CPU that the operation is finished by causing an interrupt. 2 Interrupt Hardware may trigger an interrupt at any time by sending a signal to the CPU. Software may trigger an interrupt by executing a special operation called a system call. When the CPU is interrupted, it stops what it is doing and immediately transfers execution to an address where the service routine for the interrupt is located. The CPU resumes the interrupted computation when the interrupt service routine is complete. Courtesy: https://www.shiksha.com/online- courses/articles/interrupts-in-operating-system/ 3 Multiprogramming Multiprogramming (batch system) is needed for efficiency. It organizes jobs (code and data), so the CPU always has one to execute. A subset of the total jobs in the system is kept in memory. One job is selected and run via job scheduling. When it has to wait (for I/O, for example), OS switches to another job. 4 Time-Sharing Time-sharing (multitasking): The CPU switches jobs so frequently that users can interact with each job while running, creating interactive computing. Providing each user with a small portion of a time-shared computer. Each user has at least one separate program in memory, called a process. Each process typically executes for only a short time. If several jobs are ready to run at the same time → CPU scheduling If processes don’t fit in memory, swapping moves them in and out to Courtesy: https://www.geeksforgeeks.org/time-sharing-operating-system/ run. 5 What is an Operating System? Ivy Peng, Stefano Markidis KTH Royal Institute of Technology 1 What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware. 2 Operating System Goals 01 02 03 Execute user Make the Use the computer programs and computer system hardware in an make solving user convenient to use. efficient manner. problems easier. 3 What do Operating Systems do? OS is a OS is a control resource program allocator Controls execution Manages all of programs to prevent errors and resources. improper use of the computer. Decides between conflicting requests for efficient and fair resource use. 4 Operating Systems Definition The operating system is the one program running at all times on the computer, usually called the kernel. Everything else is either a system program or an application program. Courtesy: https://developer.ibm.com/articles/l-linux-kernel/ 5

Use Quizgecko on...
Browser
Browser