
CS485G Spring 2015 42
47 System calls invoked by C library routines
1. Many C library routines include system calls.
(a) printf() calls write() which executes a system call.
(b) malloc() might call sbrk() to increase the space for the heap.
48 Processes
1. A process is an instance of a running program.
2. Each process has its own virtual memory, which it can treat as its
own private domain.
3. Each process may treat the CPU as its own as well.
4. The kernel hides that fact that the processes are sharing both memory
and the CPU.
5. The kernel schedules the processes so that they each get a “fair”
share of the CPU.
(a) Each process can pretend that it has the full use of the CPU: disk
and I/O operations seem immediate, and other processes don’t
interfere.
(b) In fact, the kernel often stops running process A and starts run-
ning process B. This process switch involves a context switch
from A to the kernel, a scheduling decision, and then a context
switch from the kernel to B.
6.
Lecture 26, 4/3/2015
7. The kernel arranges memory maps so that the MMU hardware can
redirect all memory accesses that each process makes.
8. The fork() system call asks the kernel to create a new process.
(a) Lab 4 showed this material.
(b) Say A submits the call.
(c) The kernel builds a new process B.
(d) B shares all of A’s code and has a new copy of all of A’s data and
stack. B’s program counter (PC) is identical to A’s.
(e) Therefore both A and B see a return from fork().
Comentários a estes Manuais