`
tuicwy
  • 浏览: 8198 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

Processes

阅读更多

4.1

 

A process is more than the program code, which is sometimes known as the text section. It also
includes the current activity, as represented by the value of the program counter
and the contents of the processor's registers. A process generally also includes the
process stack, which contains temporary data (such as method parameters, return
addresses, and local variables), and a data section, which contains global variables.
A process may also include a heap, which is memory that is dynamically allocated
during process run time.

 

Process Control Block

Each process is represented in the operating system by a process control block(PCB)—also called a task control block. A PCB is shown in Figure 4.2. It contains many pieces of information associated with a specific process, including these:
• Process state: The state may be new, ready, running, waiting, halted, and so on.
• Program counter: The counter indicates the address of the next instruction to be executed for this process.
• CPU registers: The registers vary in number and type, depending on the computer architecture. They include accumulators, index registers, stack pointers, and general-purpose registers, plus any condition-code information. Along with the program counter, this state information must be saved when an interrupt occurs, to allow the process to be continued correctly afterward (Figure 4.3).
• CPU-scheduling information: This information includes a process priority,pointers to scheduling queues, and any other scheduling parameters. (Chapter 6 describes process scheduling.)
• Memory-management information: This information may include such
information as the value of the base and limit registers, the page tables, or the segment tables, depending on the memory system used by the operating system (Chapter 9).
• Accounting information: This information includes the amount of CPU and real time used, time limits, account numbers, job or process numbers, and so on.
• I/O status information: This information includes the list of I/O devices allocated to the process, a list of open files, and so on.

 

4.2

 

Scheduling Queues  The list of processes waiting for a particular I/O device is called a device queue. Each device has its own device queue

 

Often, in a batch system, more processes are submitted than can be executed immediately. These processes are spooled to a mass-storage device (typically a disk), where they are kept for later execution. The long-term scheduler, or job scheduler, selects processes from this pool and loads them into memory for execution. The short-term scheduler, or CPU scheduler, selects from among the
processes that are ready to execute and allocates the CPU to one of them.

 

When a context switch occurs, the kernel saves the context of the old process in its PCB and loads the saved context of the new process scheduled to run. Context-switch time is pure overhead, because the system does no useful work while switching. Its speed varies from machine to machine, depending
on the memory speed, the number of registers that must be copied, and the existence of special instructions (such as a single instruction to load or store allregisters)

 

4.3

 

Process Creation

 

In general, a process will need certain resources (CPU time, memory, files, I/Odevices) to accomplish its task. When a process creates a subprocess, that subprocess may be able to obtain its resources directly from the operating system, or it may be constrained to a subset of the resources of the parent process. The parent may have to partition its resources among its children, or it may be able to
share some resources (such as memory or files) among several of its children. Restricting a child process to a subset of the parent's resources prevents any process from overloading the system by creating too many subprocesses.

 

There are also two possibilities in terms of the address space of the new process:

1. The child process is a duplicate of the parent process (it has the same program and data as the parent).
2. The child process has a new program loaded into it.

 

4.5

 

Interprocess Communication

 

IPC provides a mechanism to allow processes to communicate and to synchronize their actions without sharing the same address space. IPC is particularly useful in a distributed environment, where the communicating processes may reside on different computers connected with a network.

  • 大小: 15.6 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics