






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This lab report is for System Engineering course. It was submitted to Katyayani Yatindra at Bengal Engineering and Science University. It includes: Markov, Process, Premptive, Theoretical, Probability, MATLAB, Code, Results, Stochastic, Time-varying
Typology: Exercises
1 / 10
This page cannot be seen from the preview
Don't miss anything!







Given a single server, determine the probability the server remains busy.
Assume the packet arrival time is distributed by ‘Poisson Distribution’ and service time is
distributed by ‘Exponential Distribution’.
THEORETICAL PROBABILITY
( )
for λ=5 and μ=15 ,P(1)=0.
( )
λ=5 and μ=15 ,P(0)=0.
MATLAB RESULTS
p_1 =0.
p_0 =0.
MATLAB CODE
clear all clc lambda=5; A=exprnd(lambda,1,5001); P(1)=A(1); for i=2:5001 P(i)=A(i)+P(i-1);%Poisson dist from exp end arrival=P; %inter arrival time service=exprnd(15,1,5000); %exponential distribution [l m]=size(arrival);
If ‘4’ number of servers are available, and packets arrive through a single channel, what is
the probability ‘4’ number of servers remain busy simultaneously.
λ=5 and μ=5 P(0)=0.369, P(1)=0.369, P(2)=0.1845, P(3)= 0.
clear all close all clc lambda=5; A=exprnd(lambda,1,500); P(1)=A(1); for i=2: P(i)=A(i)+P(i-1); %Poisson dist from exp end arrival=P; service=exprnd(5,1,500); [l m]=size(arrival); %% initialization %first element=arrival time %2nd element=service time %3rd element=busy
S1=[arrival(1) service(1) 1]; S2=zeros(1,3); S3=zeros(1,3); S4=zeros(1,3); sum=1; %number of server busy( sum of flags of servers) n1=0; n2=0;
, 0 , 1 , 2 , ,. /!
/!
0
j s k
j P (^) s
k
k
j
j
n3=0; n4=0; b= %% Execution for i=2:m- t=arrival(i)+service(i-1);
if S1(3)== if (S1(1)+S1(2))<arrival(i) S1(3)=0; disp('S1 is free') end end if S2(3)== if (S2(1)+S2(2))<arrival(i) S2(3)=0; disp('S2 is free') end end if S3(3)== if (S3(1)+S3(2))<arrival(i) S3(3)=0; disp('S3 is free') end end if S4(3)== if (S4(1)+S4(2))<arrival(i) S4(3)=0; disp('S4 is free') end end sum=S1(3)+S2(3)+S3(3)+S4(3); if sum== n1=n1+1; elseif sum== n2=n2+1; elseif sum== n3=n3+1; elseif sum== n4=n4+1; end %% Assigning data to free server D=[S1(3) S2(3) S3(3) S4(3)]; j=find(D==0); if ((isempty(j))) disp('all server are busy') b=b+1; elseif j(1)== S1(1)=arrival(i); S1(2)=service(i); S1(3)=1; disp('S1 is bze')
elseif j(1)== S2(1)=arrival(i); S2(2)=service(i); S2(3)=1; disp('S2 is bze') elseif j(1)== S3(1)=arrival(i); S3(2)=service(i); S3(3)=1; disp('S3 is bze') elseif j(1)== S4(1)=arrival(i); S4(2)=service(i); S4(3)=1; disp('S4 is bze') end
Suppose, ‘3’ number of servers are available, and packets arrive through two channels,
channel A and channel B, with packets from B given a higher priority. What is the
probability that packets from channel A are
i. blocked due to unavailability of servers?
ii. forced terminated due to preemption?
clear all close all clc lambda1=5; a=exprnd(lambda1,1,10000); P(1)=a(1); for i=2: P(i)=a(i)+P(i-1);%Poisson dist from exp end arrival1=P; A=exprnd(5,1,10000); lambda2=5; a1=exprnd(lambda2,1,10000); P2(1)=a1(1); for i=2: P2(i)=a1(i)+P2(i-1);%Poisson dist from exp end arrival2=P2; B=exprnd(5,1,5000); [l m]=size(A); % A has higher priority than B %%% 1st element arrival %%% 2nd element service time
%%% 3rd element flag 1 for A, 2 for B & 0 for free S1=[0 0 0 ]; S2=[0 0 0 ]; S3=[0 0 0 ]; Arrival=[0 0]; block=0;kickout=0; %%% A has higher priority while B has lower priority for i=1:1:m if arrival1(i)>arrival2(i) Arrival(1)=arrival2(i); %assignment of time which is less Arrival(2)=2; else Arrival=arrival1(i); Arrival(2)=1; end if (S1(3)~=0) if Arrival(1)<(S1(1)+S1(2)) S1(3)=0; end end if (S2(3)~=0) if Arrival(1)<(S2(1)+S2(2)) S2(3)=0; end end if (S3(3)~=0) if Arrival(1)<(S3(1)+S3(2)) S3(3)=0; end end D=[S1(3) S2(3) S3(3)]; j=find(D==0); if (S1(3)==1 && S2(3)==1 && S3(3)==1) %if all server having data from A disp('all server have data from A'); block=block+1; elseif(isempty(j)) %if no server is busy j1=find(D==2); if(isempty(j)) elseif j(1)==1 %%checking for the server with data from B for kickout S1(1)=Arrival(1); kickout=kickout+1; if Arrival(2)== S1(2)=A(i); S1(3)=1; else S1(2)=B(i); S1(3)=2; end elseif j(1)== S2(1)=Arrival(1); kickout=kickout+1; if Arrival(2)== S2(2)=A(i); S2(3)=1;