To Kernel Mode and Back
9.7.2 To Kernel Mode and Back
The steps of performing a system call were outlined on page 1.3. Here we give some more details. Recall that a process actually has two stacks: one is the regular stack that resides in the stack segment and is used by the user-level program, and the other is the kernel stack that is part of the per-process kernel data, together with the u-area. Making a system call creates frames on both stacks, and uses the u-area as a staging area to pass data from user mode to kernel mode and back. System calls are actually represented by library functions. Thus making a system call starts by calling a normal library function, in user mode. This entails the creation of a call frame on the user stack, which contains the information required to return to the calling context. It may also contain the arguments passed to the library function. The information regarding what system call is being requested, and what argu- ments are provided, is available to the user-level library function. The question is how to pass this information to the kernel-mode system call function. The problem is that the user-level function cannot access any of the kernel memory that will be used by the kernel-mode function. The simplest solution is therefore to use an agreed register to store the numberical code of the requested system call. After storing this code, the library function issues the trap instruction, inducing a transition to kernel mode. The trap instruction creates a call frame on the kernel stack, just like the function- call instruction which creates a call frame on the user stack. It also loads the PC with the address of the system’s entry point for system calls. When this function starts to run, it retrieves the system call code from the agreed register. Based on this, it knows how many arguments to expect. These areguments are then copied from the last call frame on the user stack which can be identified based on the saved SP register value to a designated place in the u-area. Once the arguments are in place, the actual function that implements the system call is called. All these funcitons retrieve their arguments from the u-area in the same way. Exercise 141 Why do the extra copy to the u-area? Each system call function can get the arguments directly from the user stack When the system call function completes its task, it propagates its return value in the same way, by placing it in a designated place in the u-area. It then returns to its caller, which is the entry point of all system calls. This function copies the return value to an agreed register, where it will be found by the user-level library function. 1839.8 Error Handling
Parts
» | Komputasi | Suatu Permulaan
» Operating System Functionality | Komputasi | Suatu Permulaan
» Abstraction and Virtualization | Komputasi | Suatu Permulaan
» Hardware Support for the Operating System
» Roadmap | Komputasi | Suatu Permulaan
» Scope and Limitations | Komputasi | Suatu Permulaan
» Performance Metrics | Komputasi | Suatu Permulaan
» Statistical Characterization of Workloads
» Analysis, Simulation, and Measurement
» Modeling: the RealismComplexity Tradeoff
» Waiting in Queues Queueing Systems
» Queueing Analysis Queueing Systems
» Incremental Accuracy Simulation Methodology
» Workloads: Overload and Lack of Steady State
» Summary | Komputasi | Suatu Permulaan
» Process States What is a Process?
» Operations on Processes and Threads
» Multiprogramming and Responsiveness Having Multiple Processes in the System
» Multiprogramming and Utilization Having Multiple Processes in the System
» Multitasking for Concurrency The Cost
» Performance Metrics Scheduling Processes and Threads
» Handling a Given Set of Jobs
» Using Preemption Scheduling Processes and Threads
» Priority Scheduling Scheduling Processes and Threads
» Starvation, Stability, and Allocations
» Fair Share Scheduling Scheduling Processes and Threads
» Concurrency and the Synchronization Problem
» Mutual Exclusion Algorithms Mutual Exclusion for Shared Data Structures
» Semaphores and Monitors Mutual Exclusion for Shared Data Structures
» Locks and Disabling Interrupts
» Deadlock and Livelock Resource Contention and Deadlock
» A Formal Setting Resource Contention and Deadlock
» Deadlock Prevention, Avoidance, and Detection
» Real Life Resource Contention and Deadlock
» Mapping Memory Addresses | Komputasi | Suatu Permulaan
» Support for Segmentation Segmentation and Contiguous Allocation
» Algorithms for Contiguous Allocation
» Address Translation Paging and Virtual Memory
» Algorithms for Page Replacement
» Swapping | Komputasi | Suatu Permulaan
» Links Alternatives for File Identification
» Data Access Access to File Data
» Caching and Prefetching Access to File Data
» Memory-Mapped Files Access to File Data
» Mapping File Blocks Storing Files on Disk
» Reliability Storing Files on Disk
» Levels of Security System Security
» Mechanisms for Restricting Access
» User Identification | Komputasi | Suatu Permulaan
» Controling Access to System Objects
» Virtualization | Komputasi | Suatu Permulaan
» Resource Management | Komputasi | Suatu Permulaan
» Reduction Hardware Support and Co-Design
» Booting the System | Komputasi | Suatu Permulaan
» Timers Kernel Priorities Context Switching
» Kernel Address Mapping Making a System Call
» Error Handling | Komputasi | Suatu Permulaan
» Parallelism vs. Concurrency Kernel Locking Conflicts SMP Scheduling Multiprocessor Scheduling
» Supporting Multicore Environments System Composition
» Code Structure Monolithic Kernel Structure
» Microkernels | Komputasi | Suatu Permulaan
» Extensible Systems | Komputasi | Suatu Permulaan
» Naming | Komputasi | Suatu Permulaan
» Remote Procedure Call Message Passing
» Streams: Unix Pipes, FIFOs, and Sockets
» Shared Memory Programming Interfaces
» Distributed System Structures | Komputasi | Suatu Permulaan
» Example Client-Server Systems | Komputasi | Suatu Permulaan
» Middleware | Komputasi | Suatu Permulaan
» Protocol Stacks Communication Protocols
» Error Correction Implementation Issues
» TCP Congestion Control Implementation Issues
» Authentication Authentication and Security
» Security Authentication and Security
» Networked File Systems | Komputasi | Suatu Permulaan
» Load Balancing | Komputasi | Suatu Permulaan
» Requirements Scheduling in Real-Time Systems
Show more