You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/resources/process-and-threads.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -54,13 +54,13 @@ When the process terminates the PCB entry associated with it is typically remove
54
54
55
55
Processes are created through different system calls. The two most popular ones in Unix/Linux systems are [`exec()`](https://en.wikipedia.org/wiki/Exec_(system_call)) and [`fork()`](https://en.wikipedia.org/wiki/Fork_(system_call)) .
56
56
57
-
- `fork()`: When the `fork()` system call is invoked, the OS creates a new memory region (address space) for the child process and copies the contents of the text, data and stack/heap segments of the parent into corresponding segments of the new address space. Thus, the contents of memory allocated to the child process will be (well - almost!) identical to that of the parent at the time of completion of the `fork()` operation. A separate [PCB](https://en.wikipedia.org/wiki/Process_control_block) entry will be created for the child process, and the [PCB](https://en.wikipedia.org/wiki/Process_control_block) entries corresponding to files (and other resources like [semaphores](https://en.wikipedia.org/wiki/Semaphore_(programming)), pipes or [shared memory](https://en.wikipedia.org/wiki/Shared_memory)) opened by the parent will be copied to the **PCB** entry of the child as well. Hence the child process will also be able to access these resources. Both process continues execution from the instruction immediately following the `fork()` invocation. Details of the programming interface of `fork()` in Unix/Linux systems is described in [fork()](https://www.notion.so/System-calls-5455244fc8f84a38b4d06f452c2cc969?pvs=21)
57
+
- `fork()`: When the `fork()` system call is invoked, the OS creates a new memory region (address space) for the child process and copies the contents of the text, data and stack/heap segments of the parent into corresponding segments of the new address space. Thus, the contents of memory allocated to the child process will be (well - almost!) identical to that of the parent at the time of completion of the `fork()` operation. A separate [PCB](https://en.wikipedia.org/wiki/Process_control_block) entry will be created for the child process, and the [PCB](https://en.wikipedia.org/wiki/Process_control_block) entries corresponding to files (and other resources like [semaphores](https://en.wikipedia.org/wiki/Semaphore_(programming)), pipes or [shared memory](https://en.wikipedia.org/wiki/Shared_memory)) opened by the parent will be copied to the **PCB** entry of the child as well. Hence the child process will also be able to access these resources. Both process continues execution from the instruction immediately following the `fork()` invocation. Details of the programming interface of `fork()` in Unix/Linux systems is described in [fork() system call documentation](/guides/resources/system-calls.md)
58
58
59
59
60
60
61
61

62
62
63
-
- `exec()`: The `exec()` system call takes the name of an executable program on the disk as input and loads the program’s text into the text segment of the process that invoked `exec()`. The contents of stack/heap and data segments of the current process are replaced with the initial configuration of stack/heap and data segments of the newly loaded program. Thus, `exec()` completely destroys the calling process and replaces it with a new process executing a completely different code. All file (pipes and shared memory) pointers opened by the calling process are closed and not shared with the newly created process. However, the same PCB entry of the calling process will be used by the new program, and as a result, the new program executes with the same PID as the calling process. Hence technically `exec()` does not create a new process, but only “overlays” the current process with new code and execution context. (Linux/Unix systems provide a family of similar functions implementing essentially the same `exec()` functionality, but with minor technical differences). Further details may be found in the page [[exec](https://en.wikipedia.org/wiki/Exec_(system_call))]
63
+
- `exec()`: The `exec()` system call takes the name of an executable program on the disk as input and loads the program’s text into the text segment of the process that invoked `exec()`. The contents of stack/heap and data segments of the current process are replaced with the initial configuration of stack/heap and data segments of the newly loaded program. Thus, `exec()` completely destroys the calling process and replaces it with a new process executing a completely different code. However, the same PCB entry of the calling process will be used by the new program, and as a result, the new program executes with the same PID as the calling process. Hence technically `exec()` does not create a new process, but only “overlays” the current process with new code and execution context. (Linux/Unix systems provide a family of similar functions implementing essentially the same `exec()` functionality, but with minor technical differences). Further details may be found in the page [[exec](https://en.wikipedia.org/wiki/Exec_(system_call))]
64
64
65
65
In the eXpServer project, we want to create server programs that connects to several clients concurrently. One way to handle this is for the server to create (an identical) child process using the `fork()` system call to handle each client request. However, this is very inefficient because creating a new address space and PCB entry, and then copying all the text, data, stack and heap to the new address space for each client connection would slow down the server considerably. Observe that the code for each child process is nearly identical and these concurrent processes can actually share most of the text and data regions as well as files and other resources.
66
66
@@ -105,7 +105,7 @@ The main Improvements achieved through multi-threading are listed below
105
105
106
106
**Non-blocking Operations**: One thread can handle blocking input/output operations while other threads can continue executing without blocking. This allows a process to make effective utilization of the CPU.
107
107
108
-
The major thread operations which we use in this project are thread creation and termination using pthread_create() , pthread_exit()and pthread_detach() . Refer the [system calls](/guides/resources/system-calls) page for more details.
108
+
The major thread operations which we use in this project are thread creation and termination using `pthread_create()` , `pthread_exit()` , `pthread_join()`and `pthread_detach()` . Refer the [system calls](/guides/resources/system-calls) page for more details.
109
109
110
110
### **Thread Control Block**
111
111
@@ -125,4 +125,4 @@ The major thread operations which we use in this project are thread creation and
125
125
126
126
Once a **detached** thread terminates, the TCB and all other resources related to the thread (such as its stack and registers) are **immediately de-allocated** by the operating system.
127
127
128
-
For programming inteface to threads in Unix/Linux enviornments, see the [system calls](/guides/resources/system-calls) page……………….
128
+
For programming inteface to threads in Unix/Linux enviornments, see the [system calls](/guides/resources/system-calls) page.
0 commit comments