Skip to content

Commit 3494efe

Browse files
committed
Added stage 15 and updated the resource pages
1 parent 6e06d0c commit 3494efe

11 files changed

+884
-360
lines changed
76.4 KB
Loading

docs/assets/resources/tcp-flow.png

223 KB
Loading
42.2 KB
Loading
Loading

docs/guides/resources/linux-epoll-tutorial.md

Lines changed: 62 additions & 24 deletions
Large diffs are not rendered by default.

docs/guides/resources/process-and-threads.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ When the process terminates the PCB entry associated with it is typically remove
5454

5555
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)) .
5656

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)
5858

5959
6060

6161
![fork.png](/assets/resources/fork.png)
6262

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))]
6464

6565
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.
6666

@@ -105,7 +105,7 @@ The main Improvements achieved through multi-threading are listed below
105105

106106
**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.
107107

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.
109109

110110
### **Thread Control Block**
111111

@@ -125,4 +125,4 @@ The major thread operations which we use in this project are thread creation and
125125

126126
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.
127127

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

Comments
 (0)