Linux Operating System许富皓.pptVIP

  • 7
  • 0
  • 约3.78万字
  • 约 92页
  • 2019-04-20 发布于湖北
  • 举报
Linux Operating System 許 富 皓 Chapter 10 System Calls System Call Operating systems offer processes running in User Mode a set of interfaces to interact with hardware devices such as the CPU disks and printers. Unix systems implement most interfaces between User Mode processes and hardware devices by means of system calls issued to the kernel. POSIX APIs vs. System Calls An application programmer interface is a function definition that specifies how to obtain a given service A system call is an explicit request to the kernel made via a software interrupt. From a Wrapper Routine to a System Call Unix systems include several libraries of functions that provide APIs to programmers. Some of the APIs defined by the libc standard C library refer to wrapper routines (routines whose only purpose is to issue a system call). Usually, each system call has a corresponding wrapper routine, which defines the API that application programs should employ. APIs and System Calls An API does not necessarily correspond to a specific system call. First of all, the API could offer its services directly in User Mode. (For something abstract such as math functions, there may be no reason to make system calls.) Second, a single API function could make several system calls. Moreover, several API functions could make the same system call, but wrap extra functionality around it. Example of Different APIs Issuing the Same System Call In Linux, the malloc( ) , calloc( ) , and free( ) APIs are implemented in the libc library. The code in this library keeps track of the allocation and deallocation requests and uses the brk( ) system call to enlarge or shrink the process heap. P.S.: See the section Managing the Heap in Chapter 9. The Return Value of a Wrapper Routine Most wrapper routines return an integer value, whose meaning depends on the corresponding system call. A return value of -1 usually indicates that the kernel was unable to satisfy the process request. A failur

文档评论(0)

1亿VIP精品文档

相关文档