The basic concept about process and thread (1)
In my opinion, PCB is the only thing which can prove a process existing in the system.And if we want to know much about process and thread, here are the concepts we should learn, in order to understand PCB struct(as task_struct in Linux).
Key words:
/Activate a process
process activation is straightforward, involving a status change to active and a possible call on the scheduler. The latter permits the option of preemption scheduling if the activated process becomes ready_a.A process may activate any of its known descendants, in particular,its child.
/Asynchronous Transfer Mode(ATM)
an international standard,promoted by telephone companies as a means to handle voice and data messages.
/Binary heap
A binary heap is a complete binary tree where the value(priority number in our case)at the root of any subtree is always smaller than the value of any other node in the subtree. A data structure that works well when priorities are not fixed but can range over a large domain of values is the binary heap.
/Blocked list
The field status. List point to one of several possible lists on which the process may reside.When the process blocks on a resource, it has an entry on waiting list associated with the resource.
/Busy wait (spinning)
The process continue running in a wait loop while another process is in the CS.
/Clock server
consider a simple clock serve with three procedures. Update_Clock, Get_Time,and Set_Clock, Update_Clock is directly connected to a periodic hardware ticker,whereas the other two procedures are used by processes to access and set the current time.
/Context switch
Select another ready process from a ready list(RL) of process and transfer control to it. Thus , the new process continues executing on the processor, instead of the original process. Such a processor reassignment is called a context switch.
/Control block Descriptor
ID
/Countdown timer
a process or thread requires a timeout signal at some specified time in the future. In its purest form, the process wishes to delay, the basic function provided by a countdown timer is:Delay(tdel) and Set-Timer(tdel).
/Exception
Internal interrupts or traps are those that occur directly as a consequence of the current computation.These also are called exceptions because they identify some exceptional,usually error,condition associated with the current instruction.
/Interrupt handler(IH)
interrupt service routine,generally called the interrupt handler,associated with this type of interrupt.
/Kernel
mechanisms for process creation,activation,and termination,and for synchronization,communication,and resource control from the lowest level or kernel of all OS and concurrent programming systems.The OS kernel is a basic set of objects, primitive operations, data structures,and processes from which the remainder of the system may be constructed. The kernel includes any part of the system that resides permanently the set of possible function and runs in a supervisory mode. The set of possible function and objects in a kernel can be divided into four classes:1)Process and thread management2)Interrupt and trap handling3)resource management4)Input and output.
/Nucleus
another name for Kernel.
/Open System Interconnection Reference Model(OSI)
the open systems interconnection reference model(OSI),developed by the international standards organization,Specifies seven layers, interfaces,and protocols for communication: Physical,data link, network, transport,session,presentation,and application.
/Process control block(PCB)
a process descriptor or process control block(PCB) is constructed at process creation and represents the process during its existence.Process descriptors(PCB)are used and modified by basic process and resource operations, interrupt routines, and schedulers.We have grouped the items comprising the process descriptor into five categories according to their primary purpose as follows:1,identification 2,state vector3 ,state 4,Creation free 5,other information
/Priority queue
A priority queue combines several queues into one common data structure. In addition to its application data, each queue element contains a priority associated with the corresponding object.
/Process descriptor
P=get_PCB(pid)
/Process state vector
CPU_State, Processor_ID, Memory, Open_Files, Other rsources.
/Process status
The status of a process P may be described by a structure with two components: Status.Type and Status.List.
/queue
to maintain these queues, at least two operations are needed, one to append a new element x to a queue Q and one to remove the first element from a given queue.Common forms for there operations are:insert (queue Q, element x) and remove (queue Q,element X)
/Ready list(RL) (a short_term scheduling queue)
waiting for allocation of CPU by scheduler.
/Release operation release(res) {
Deallocate(res,self);
if(Process_blocked_on(res, pr))
Allocate(res,pr);
unblock(pr,res);
scheduler();
}
/Request operation
request(res){
if(Free(res))
Allocate(res,self)
Else{
Block(self,res);
Scheduler();
}
}
/Spinning lock
the spinning operations are used extensively for mutual exclusion locks,where Pb(sb) is a lock request, say mutex_lock(sb), and Vb(sb) is an unlock, say mutex_unlock(sb).
/Suspend a process
suspend(pid){
P=Get_PCB(pid);
s=p→status.Type;
If((s=='blocked_a')||(s=='blocked_s'))
p→status.Type=blocked_s';
Else p→status.Type='ready_s';
If(s=='rinning'){
CPU=p→processor_ID;
p→CPU_state=Interrupt(CPU);
Scheduler();
}
}
/Test and set
instruction(TS) TS(R,X) an instruction to test and set a memory location in one indivisible, atomic operation. R is a CPU register, X is an arbitrary location that can contain either a 0 or a 1.
/Thread
the generally idea of efficiently sharing resources, especially address spaces, among contemporary system provide this facility. The scheduling units are known as threads.
/Thread descriptor
a Create-process operation typically establishes the resources for a set of yet-to-be define threads, and creates one initial thread.Thus, both a new descriptor and new thread descriptor are created.