File: context.html

package info (click to toggle)
lg-issue23 4-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,360 kB
  • ctags: 430
  • sloc: makefile: 36; sh: 4
file content (105 lines) | stat: -rw-r--r-- 4,718 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Generator" CONTENT="Microsoft Word 97">
   <META NAME="Template" CONTENT="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
   <META NAME="GENERATOR" CONTENT="Mozilla/4.01b6C [en] (X11; I; Linux 2.1.47 i486) [Netscape]">
   <TITLE>Processes and Process Context</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">
&nbsp;<FONT COLOR="#3366FF"><FONT SIZE=+3><B>Process
Context</B></FONT></FONT>

<P><FONT SIZE=+1>&nbsp;Each time a process is removed from access to the
processor, sufficient information on its current operating state must be
stored such that when it is again scheduled to run on the processor it
can resume its operation from an identical position. This operational state
data is known as its <I>context</I> and the act of removing the process's
thread of execution from the processor (and replacing it with another)
is known as a <I>process switch </I>or<I> context switch.</I></FONT>

<P><FONT SIZE=+1><I>&nbsp;</I>The distinction is made here between the
condition where a process is removed from the processor completely and
is replaced by another process (a process switch) and the case where the
process state is stored while execution is interrupted temporarily (a context
switch). Note that a process switch performs a superset of the operations
required for the context switch. The latter case may be when an external
interrupt is serviced or when a system call necessitates a switch from
user mode to system mode. In the case of the process switch much more information
must be saved in order to later restore the process context than in the
second case where the process remains resident in memory while it's thread
of execution is interrupted.</FONT>

<P><FONT SIZE=+1>&nbsp;The context of a process includes its address space,
stack space, virtual address space, register set image (e.g. Program Counter
(PC), Stack Pointer (SP), Instruction Register (IR), Program Status Word
(PSW) and other general processor registers), updating profiling or accounting
information, making a snapshot image of its associated kernel data structures
and updating the current state of the process (waiting, ready, etc).</FONT>

<P><FONT SIZE=+1>&nbsp;This state information is saved in the process's
process control block which is then moved to the appropriate scheduling
queue. The new process is moved to the CPU by copying the PCB info into
the appropriate locations (e.g. the program counter is loaded with the
address of the next instruction to execute).</FONT>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=7 WIDTH="491" >
<TR>
<TD VALIGN=TOP WIDTH="48%">
<UL><B><FONT COLOR="#FF0000"><FONT SIZE=+1>Linux</FONT></FONT></B></UL>
</TD>

<TD VALIGN=TOP WIDTH="4%">
<UL><FONT SIZE=+1>&nbsp;</FONT></UL>
</TD>

<TD VALIGN=TOP WIDTH="48%">
<UL><B><FONT COLOR="#FF0000"><FONT SIZE=+1>Windows NT</FONT></FONT></B></UL>
</TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="48%">
<UL><FONT SIZE=+1>Each process's context is described by a <I>task_struct
</I>structure. The task_struct holds data such as the scheduling policy,
scheduler priority, real time priority, processor allowed time counter,
processor registers, file handles (files_struct), virtual memory (mm_struct).&nbsp;</FONT></UL>
</TD>

<TD VALIGN=TOP WIDTH="4%">
<UL><FONT SIZE=+1>&nbsp;</FONT></UL>
</TD>

<TD VALIGN=TOP WIDTH="48%">
<UL><FONT SIZE=+1>The kernel maintains a view of a process or thread known
as a kernel process object or kernel thread object respectively. These
contain just the information the kernel needs to effectively switch between
processes or threads.</FONT></UL>
</TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="48%">
<UL><FONT SIZE=+1>&nbsp;When a process switch is made the scheduler saves
the process's task_struct and replaces the current tasks pointer with a
pointer to the new process's task_struct, restoring its memory access and
register context. This may be assisted by hardware.</FONT></UL>
</TD>

<TD VALIGN=TOP WIDTH="4%">
<UL><FONT SIZE=+1>&nbsp;</FONT></UL>
</TD>

<TD VALIGN=TOP WIDTH="48%">
<UL><FONT SIZE=+1>&nbsp;The kernel makes a context switch by pushing context
information onto the current kernel mode stack, for a process it also saves
the address of it's page table directory so that it's address space is
maintained.&nbsp;</FONT></UL>
</TD>
</TR>
</TABLE>
&nbsp;
<BR>&nbsp;
<DIV ALIGN=right><A HREF="multiproc.html"><IMG SRC="../gx/flower/cyan_lef.gif" BORDER=0 HEIGHT=31 WIDTH=31></A><A HREF="page1.html"><IMG SRC="../gx/flower/cyan_up.gif" BORDER=0 HEIGHT=31 WIDTH=31></A><A HREF="threads.html"><IMG SRC="../gx/flower/cyan_rig.gif" BORDER=0 HEIGHT=31 WIDTH=31></A></DIV>

</BODY>
</HTML>