Presentation is loading. Please wait.

Presentation is loading. Please wait.

Notes on Processes, Context, Context Switching The following slides contain partially quoted statements from various Wikipedia pages.

Similar presentations


Presentation on theme: "Notes on Processes, Context, Context Switching The following slides contain partially quoted statements from various Wikipedia pages."— Presentation transcript:

1 Notes on Processes, Context, Context Switching The following slides contain partially quoted statements from various Wikipedia pages.

2 fork() In computing, when a process forks, it creates a copy of itself, which is called a "child process." The original process is then called the "parent process". More generally, a fork in a multithreading environment means that a thread of execution is duplicated, creating a child thread from the parent thread.computingprocesschild processparent processmultithreadingthread Under Unix and Unix-like operating systems, the parent and the child processes can tell each other apart by examining the return value of the fork() system call. In the child process, the return value of fork() is 0, whereas the return value in the parent process is the PID of the newly-created child process.UnixUnix-likeoperating systemssystem call PID The fork operation creates a separate address space for the child. The child process has an exact copy of all the memory segments of the parent process, though if copy-on-write semantics are implemented actual physical memory may not be assigned (i.e., both processes may share the same physical memory segments for a while). Both the parent and child processes possess the same code segments, but execute independently of each other.address spacecopy-on-write

3 CreateProcess Function Creates a new process and its primary thread. The new process runs in the security context of the calling process.

4 Syntax BOOL WINAPI CreateProcess( __in_opt LPCTSTR lpApplicationName, __inout_opt LPTSTR lpCommandLine, __in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes, __in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes, __in BOOL bInheritHandles, __in DWORD dwCreationFlags, __in_opt LPVOID lpEnvironment, __in_opt LPCTSTR lpCurrentDirectory, __in LPSTARTUPINFO lpStartupInfo, __out LPPROCESS_INFORMATION lpProcessInformation );

5 Context In computer science, a task context (process, thread...) is the minimal set of data used by this task that must be saved to allow a task interruption at a given date, and a continuation of this task at the point it has been interrupted and at an arbitrary future date.processthreadinterruption The concept of context assumes significance in the case of interruptible tasks, wherein upon being interrupted the processor saves the context and proceeds to serve the Interrupt service routine. Thus the smaller the context the smaller is the latency.Interrupt service routine These data are located in: – Processor registers – Memory used by the task – On some Operating systems, control registers used by the system to manage the taskOperating systems The storage memory (files) is not concerned by the "task context" in the case of a context switch; even if this can be stored for some uses (Checkpointing).context switch

6 Context Switch A context switch is the computing process of storing and restoring the state (context) of a CPU such that multiple processes can share a single CPU resource.computingstatecontextCPUprocesses The context switch is an essential feature of a multitasking operating system. multitaskingoperating system Context switches are usually computationally intensive and much of the design of operating systems is to optimize the use of context switches.operating systems A context switch can mean a register context switch, a task context switch, a thread context switch, or a process context switch. What constitutes the context is determined by the processor and the operating system.registerthread

7 State In computer science and automata theory, a state is a unique configuration of information in a program or machine.computer scienceautomata theory One of the key concepts in computer programming is the idea of state, essentially a snapshot of the measure of various conditions in the system.computer programming

8 Interrupts In computing, an interrupt is an asynchronous signal from hardware indicating the need for attention or a synchronous event in software indicating the need for a change in execution.computingasynchronous A hardware interrupt causes the processor to save its state of execution via a context switch, and begin execution of an interrupt handler.processorcontext switchexecution interrupt handler Software interrupts are usually implemented as instructions in the instruction set, which cause a context switch to an interrupt handler similar to a hardware interrupt.instructionsinstruction set Interrupts are a commonly used technique for computer multitasking, especially in real-time computing. Such a system is said to be interrupt-driven. [1]computer multitasking [1] An act of interrupting is referred to as an interrupt request ("IRQ").interrupt request

9


Download ppt "Notes on Processes, Context, Context Switching The following slides contain partially quoted statements from various Wikipedia pages."

Similar presentations


Ads by Google