### Computer Network | Capacity of Channel and Pipelining

#### Capacity of Channel

Capacity can be measured by counting number of packets of data embedded in a snapshot of a channel while it is transferring maximum amount of data it can hold. Which means the holding capacity of channel during transmission. If a half duplex channel can send $$n$$ bits per second(Band Width) the it has a propagation delay($$T_p$$) of $$p$$ seconds, channel will have a capacity $$n*p$$ bits.

$$Capacity\ of\ channel = Band\ Width( BW ) * Transmission\ dealy( T_p )$$

Channels with high capacity is called thick channels/thick pipes and those with lower capacity is called thin pipes. Since the sender has to wait until receive acknowledgement from the receiver, in efficient usage of available space on thick pipes makes it not suitable for stop and wait protocol. We have efficiency( $$\eta$$ ) of stop and wait protocol, which can be rewrite as,

$$\eta =\frac{1}{1 +2\ a} =\frac{1}{1 +\frac{2\ T_p}{T_t}} \\ \\ \eta =\frac{1}{1 +\frac{2\ T_p\ BW}{L}} \\ \\ \eta =\frac{1}{1 +\frac{2\ T_p\ BW}{L}}=\frac{1}{1 +\frac{ ChannelCapacity }{L}}$$

For a full duplex communication link, Channel Capacity will be twice that of half duplex $$[Channel\ Capacity= 2\ T_p\ BW]$$ , since it can communicate to and fro at same time with out collision.

$$\Rightarrow$$ Efficiency of stop and wait protocol is inversely proportional to channel capacity. So it will give poor performance on a channel with higher capacity, this can be improved by a method called pipelining.

#### Pipelining/ Sliding window protocol

Let $$T_t = 1 \mu s$$ and $$T_p = 1.5 \mu s$$

If I apply stop and wait protocol for data transmission, $$\ \ efficiency\ \ \eta = \frac{1}{1+2a}= \frac{1}{1+2* \frac{1.5}{1}} = \frac{1}{4}$$ The efficiency is very less. The sender has used only small portion of the total time, because it has to wait during the to and fro transmissions until the acknowledgment from the receiver reaches at sender.

In order to increase the efficiency of the transmission this waiting time should be used for the sending of more number of packets and each of the packets transmitted from the sender has to be copied to the window buffer at the sender to keep track of its success rate of transmission, until its acknowledgment messages reaches at sender. Data which are already acknowledged are stored pops out from the window, and inside the window we keep only those which are already transmitted and did not acknowledged till that time. So the number of such data packets defines the size of the window and which is a function of propagation and transmission delays.

By observing the timing diagram it is found that sender window size $$W_s = 1+ 2a$$

In order to identify data packet stored in window each of them should have a sequence number, which can be in increasing order of of natural numbers. But as the number of data packets grew up, the space to store sequence number will also become high. So it is a more convenient to use sequence number as minimum as possible with lower size. To do that sequence number last packet whose acknowledgement had received can be used.

$$Window\ size\ W_s = min( 1 + 2a, 2^N) \\ \\ N-\ Number\ of\ bits\ available\ in\ sequence\ number\ field \\ \\ Minimum\ sequence\ number\ required\ = 1 + 2a \\ \\ Bits\ used\ for\ number\ of\ sequence\ number\ = \left \lceil log_2(1+ 2a) \right \rceil$$

Q) Tt = 1 ms and Tp = 56.5 ms What should be sender window size to get maximum efficiency?

$$\\ a = \frac{T_p}{T_t} = \frac{56.5}{1}= 56.5 \\ \\ N = \left \lceil log(1+ 2a) \right \rceil = \left \lceil log_2(1+ 2*56.5) \right \rceil = \left \lceil log_2(114) \right \rceil = 7 \\ \\ Window\ size\ W_s = min( 1 + 2a, 2^N) = min( 114, 2^7) = min( 114, 128) = 114 \\$$

Notes:
Half Duplex
A half duplex communication medium is a channel which can be used either for sending data or receiving data at an instant, which means even though it provides bidirectional data path, the transmission time and receival time will be different.

Full Duplex
Full duplex channels are those transmission mediums where sending and receiving can be done simultaneously. Which means, the channel will have the capability to transport data from receiver to sender and from sender to receiver on same time.

### Operating Systems | Scheduling Algorithms : Round Robin

Round Robin Features : Most popular algorithm of all Practically implementable Implementable with basic data structures like queue Extremely lesser starvation Optimum efficiency can be set by controlling time quantum The round robin algorithm will continuously switch between processes if a process in CPU (under execution) exceeds a time limit set by OS called time quantum . Flow Chart : Scheduler allocated process to for execution. CPU starts monitoring the execution time right after from allocation. If the process completes its execution before exceeding time quantum, OS forwards the process to termination state. else, the processes gets preempted once the time quantum limit exceeded and if the process finished at this moment, OS moves the process to termination state, else it moves to ready queue and iterates over the whole process listed above. Example : Consider the following table of processes and calculate completion time, turn around time and waiting tim

### Operating Systems | Concept of shared memory and critical section

While printing your document opened in Adobe Acrobat Reader, if you gave a same command for document opened in Microsoft Word! How will it be? These are the real time situations where two processes competing together for same resources due to improper process synchronization. An unstructured access approval to these resources may lead to a abnormal output or a breach in information security or even it may cause for data loss. In the above case which might be a bunch of over-written papers coming out of the printer connected to that system. Shared Memory and Critical Section Resources or memory spaces where different processes have access to read, write or update at same time are known as shared memory . And the piece of program which tries to access the shared memory is known as Critical Section . There are situations where an operating system need to handle multiple request from critical sections of various processes in a machine , in order to maintain da

### Operating Systems | Lock Variable Synchronization Mechanism

To learn lock variable synchronization mechanism, you have to understand different modes of execution of instructions in an operating system. Basically there are two modes of execution in a system, User Mode and Kernel Mode. The unrestricted access to any resources in the system, for executing instructions in Kernel Mode makes resources available only for most trusted basic level functions of operating system . Direct access of hardware or memory references are not allowed in User Mode , due security concerns over higher level applications. System APIs provide a path way to reference these resources. Features of Lock Variable A software logic implemented in User Mode. A Busy waiting method of synchronization. Multiple processes can be handled by single mechanism. There are two basic section for every synchronization method, which decides the nature of that algorithm, Entry and Exit sections. Arranged as shown. Here in lo