Translation

(itstool) path: sect1/para
The boundary between the kernel- and user-level code is enforced by hardware-protection facilities provided by the underlying hardware. The kernel operates in a separate address space that is inaccessible to user processes. Privileged operations -- such as starting I/O and halting the central processing unit (CPU) -- are available to only the kernel. Applications request services from the kernel with <emphasis>system calls</emphasis>. System calls are used to cause the kernel to execute complicated operations, such as writing data to secondary storage, and simple operations, such as returning the current time of day. All system calls appear <emphasis>synchronous</emphasis> to applications: The application does not run while the kernel does the actions associated with a system call. The kernel may finish some operations associated with a system call after it has returned. For example, a <emphasis>write</emphasis> system call will copy the data to be written from the user process to a kernel buffer while the process waits, but will usually return from the system call before the kernel buffer is written to the disk.
0/11300
Context English Portuguese (Brazil) State
17,506
17.506
8.7
8,7
3,087
3,087
1.5
1,5
other machine dependent
outro dependente da máquina
6,287
6,287
3.1
3,1
routines in assembly language
rotinas na linguagem assembly
3,014
3,014
HP/UX compatibility
Compatibilidade com HP / UX
4,683
4,683
2.3
2,3
<xref linkend="table-mach-indep"/> summarizes the machine-independent software that constitutes the 4.4BSD kernel for the HP300. The numbers in column 2 are for lines of C source code, header files, and assembly language. Virtually all the software in the kernel is written in the C programming language; less than 2 percent is written in assembly language. As the statistics in <xref linkend="table-mach-dep"/> show, the machine-dependent software, excluding HP/UX and device support, accounts for a minuscule 6.9 percent of the kernel.
 
Only a small part of the kernel is devoted to initializing the system. This code is used when the system is <emphasis>bootstrapped</emphasis> into operation and is responsible for setting up the kernel hardware and software environment (see Chapter 14). Some operating systems (especially those with limited physical memory) discard or <emphasis>overlay</emphasis> the software that performs these functions after that software has been executed. The 4.4BSD kernel does not reclaim the memory used by the startup code because that memory space is barely 0.5 percent of the kernel resources used on a typical machine. Also, the startup code does not appear in one place in the kernel -- it is scattered throughout, and it usually appears in places logically associated with what is being initialized.
 
Kernel Services
Serviços do Kernel
The boundary between the kernel- and user-level code is enforced by hardware-protection facilities provided by the underlying hardware. The kernel operates in a separate address space that is inaccessible to user processes. Privileged operations -- such as starting I/O and halting the central processing unit (CPU) -- are available to only the kernel. Applications request services from the kernel with <emphasis>system calls</emphasis>. System calls are used to cause the kernel to execute complicated operations, such as writing data to secondary storage, and simple operations, such as returning the current time of day. All system calls appear <emphasis>synchronous</emphasis> to applications: The application does not run while the kernel does the actions associated with a system call. The kernel may finish some operations associated with a system call after it has returned. For example, a <emphasis>write</emphasis> system call will copy the data to be written from the user process to a kernel buffer while the process waits, but will usually return from the system call before the kernel buffer is written to the disk.
 
A system call usually is implemented as a hardware trap that changes the CPU's execution mode and the current address-space mapping. Parameters supplied by users in system calls are validated by the kernel before being used. Such checking ensures the integrity of the system. All parameters passed into the kernel are copied into the kernel's address space, to ensure that validated parameters are not changed as a side effect of the system call. System-call results are returned by the kernel, either in hardware registers or by their values being copied to user-specified memory addresses. Like parameters passed into the kernel, addresses used for the return of results must be validated to ensure that they are part of an application's address space. If the kernel encounters an error while processing a system call, it returns an error code to the user. For the C programming language, this error code is stored in the global variable <emphasis>errno</emphasis>, and the function that executed the system call returns the value -1.
 
User applications and the kernel operate independently of each other. 4.4BSD does not store I/O control blocks or other operating-system-related data structures in the application's address space. Each user-level application is provided an independent address space in which it executes. The kernel makes most state changes, such as suspending a process while another is running, invisible to the processes involved.
 
Process Management
Gerenciamento de processos
4.4BSD supports a multitasking environment. Each task or thread of execution is termed a <emphasis>process</emphasis>. The <emphasis>context</emphasis> of a 4.4BSD process consists of user-level state, including the contents of its address space and the run-time environment, and kernel-level state, which includes scheduling parameters, resource controls, and identification information. The context includes everything used by the kernel in providing services for the process. Users can create processes, control the processes' execution, and receive notification when the processes' execution status changes. Every process is assigned a unique value, termed a <emphasis>process identifier</emphasis> (PID). This value is used by the kernel to identify a process when reporting status changes to a user, and by a user when referencing a process in a system call.
 
The kernel creates a process by duplicating the context of another process. The new process is termed a <emphasis>child process</emphasis> of the original <emphasis>parent process</emphasis> The context duplicated in process creation includes both the user-level execution state of the process and the process's system state managed by the kernel. Important components of the kernel state are described in Chapter 4.
 
Process lifecycle
Ciclo de vida do processo
_
external ref='fig1' md5='__failed__'
 
+----------------+ wait +----------------+
| parent process |---------------------------------&gt;| parent process |---&gt;
+----------------+ +----------------+
| ^
| fork |
V |
+----------------+ execve +----------------+ wait +----------------+
| child process |-------&gt;| child process |-------&gt;| zombie process |
+----------------+ +----------------+ +----------------+
 
<imageobject> <imagedata fileref="fig1"/> </imageobject> <textobject> <_:literallayout-1/> </textobject> <textobject> <phrase>Process-management system calls</phrase> </textobject>
 
The process lifecycle is depicted in <xref linkend="fig-process-lifecycle"/>. A process may create a new process that is a copy of the original by using the <emphasis>fork</emphasis> system call. The <emphasis>fork</emphasis> call returns twice: once in the parent process, where the return value is the process identifier of the child, and once in the child process, where the return value is 0. The parent-child relationship induces a hierarchical structure on the set of processes in the system. The new process shares all its parent's resources, such as file descriptors, signal-handling status, and memory layout.
 
Although there are occasions when the new process is intended to be a copy of the parent, the loading and execution of a different program is a more useful and typical action. A process can overlay itself with the memory image of another program, passing to the newly created image a set of parameters, using the system call <emphasis>execve</emphasis>. One parameter is the name of a file whose contents are in a format recognized by the system -- either a binary-executable file or a file that causes the execution of a specified interpreter program to process its contents.
 
A process may terminate by executing an <emphasis>exit</emphasis> system call, sending 8 bits of exit status to its parent. If a process wants to communicate more than a single byte of information with its parent, it must either set up an interprocess-communication channel using pipes or sockets, or use an intermediate file. Interprocess communication is discussed extensively in Chapter 11.
 
A process can suspend execution until any of its child processes terminate using the <emphasis>wait</emphasis> system call, which returns the PID and exit status of the terminated child process. A parent process can arrange to be notified by a signal when a child process exits or terminates abnormally. Using the <emphasis>wait4</emphasis> system call, the parent can retrieve information about the event that caused termination of the child process and about resources consumed by the process during its lifetime. If a process is orphaned because its parent exits before it is finished, then the kernel arranges for the child's exit status to be passed back to a special system process <emphasis>init</emphasis>: see Sections 3.1 and 14.6).
 
The details of how the kernel creates and destroys processes are given in Chapter 5.
 
Processes are scheduled for execution according to a <emphasis>process-priority</emphasis> parameter. This priority is managed by a kernel-based scheduling algorithm. Users can influence the scheduling of a process by specifying a parameter (<emphasis>nice</emphasis>) that weights the overall scheduling priority, but are still obligated to share the underlying CPU resources according to the kernel's scheduling policy.
 

Loading…

User avatar None

New source string

FreeBSD Doc / books_design-44bsdPortuguese (Brazil)

New source string 11 months ago
Browse all component changes

Glossary

English Portuguese (Brazil)
No related strings found in the glossary.

Source information

Source string comment
(itstool) path: sect1/para
Labels
No labels currently set.
Source string location
book.translate.xml:555
Source string age
11 months ago
Translation file
books/pt_BR/design-44bsd.po, string 134