-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8370573
commit 7d9536c
Showing
7 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# MULTI-THREADING | ||
|
||
Thread is the smallest unit of execution within a process. Threads within the same process share memory and resources, facilitating communication and data sharing. Multi-threading is the ability of a program or an operating system to enable more than one user at a time without requiring multiple copies of the program running on the computer. | ||
|
||
Creating a thread is less expensive than creating a new process because the newly created thread uses the current process address space. | ||
|
||
**Concurrency**: Multiple threads are making progress at the same time. This is more about dealing with multiple tasks at once rather than running them simultaneously. | ||
|
||
**Non-blocking Operations**: Threads enable non-blocking I/O operations, where one thread can handle input/output operations while other threads continue executing without waiting. | ||
|
||
**Faster Response Times**: With the ability to process multiple requests concurrently, client requests can be handled more quickly, reducing the time each client waits for a response. | ||
|
||
**Handling High Loads**: Concurrent servers can scale to handle a large number of simultaneous connections, making them suitable for high-traffic applications like web servers, email servers, and database servers. | ||
|
||
![multi-threading.png](/assets/resources/multi-threading.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# UDP | ||
|
||
**User Datagram Protocol (UDP)** is part of the Transport Layer of the TCP/IP suite. UDP provides a connectionless communication method for sending data between devices. Unlike TCP, UDP does not guarantee data delivery, ordering, or error recovery. Instead, it offers a simpler, faster way to transmit data with minimal overhead. | ||
|
||
When sending data over the network from the Application layer, we create a UDP socket. To send and receive data using this socket, we use the socket programming APIs provided by the operating system. These APIs include system calls like `sendto()` and `recvfrom()`, which facilitate the transmission of data between the Application layer and the Transport layer. | ||
|
||
![udp-ip-packet.png](/assets/resources/udp-ip-packet.png) | ||
|
||
Here’s how UDP handles data: | ||
1. **Socket Creation:** | ||
- **UDP Socket:** An application creates a UDP socket using the `socket()` system call, specifying the UDP protocol. | ||
2. **Data Transmission:** | ||
- **Sending Data:** When data is sent via a UDP socket, the data is provided to the `sendto()` system call. The data is then encapsulated in UDP packets (datagrams). | ||
- **Receiving Data:** The `recvfrom()` system call is used to receive data from the socket. The received UDP datagram is then passed up to the application layer. | ||
3. **UDP Datagram Structure:** | ||
- **Datagram Format:** A UDP datagram consists of a UDP header and the data payload. The UDP header includes fields such as: | ||
- **Source Port:** The port number of the sending application. | ||
- **Destination Port:** The port number of the receiving application. | ||
- **Length:** The length of the UDP header and payload. | ||
- **Checksum:** Used for error checking, but it's optional in IPv4. |