analysis.asv

来自「8个进程的改进版CPU schedule 算法-SJF」· ASV 代码 · 共 54 行

ASV
54
字号
function Analysis(History,TB,cpubP)
%here the GlobalCycle is not the same as that in the CPU()

CycleStart=input('CycleStart:');
CycleEnd=input('CycleEnd:');
GlobalCycle=CycleEnd-CycleStart;


TQNeedByP=zeros(1,Qlen);
CountP=zeros(1,Qlen);

for i=1:Qlen
   TQNeedByP(i)=ceil(TB(i)/TQ); %..............................
end


Rounds=input('Rounds:');

%Find the User Time and CPU Bound Time
i=CycleStart+1;            %QRedeady_History start from 1
j=CycleEnd;              %this is end of the next round, do not use CycleEnd+1
UserTime=0;
CPUBoundTime=0;

for k=i:j
    curP=History(9,k);
    if (curP>0)  %if 0,sikp idle
        UserTime=UserTime+TB(curP);
        
        if (curP==cpubP)
            CPUBoundTime=CPUBoundTime+TB(curP);
        end
    end
end

%Find the User Time and CPU Bound Time and the Rounds!!
for i=1:Qlen
   fprintf('---P%d runs %d times----\n',i,CountP(i)/TQNeedByP(i));
end

%print out
disp('==========================================================')
fprintf('Rounds=%d\n',Rounds);
fprintf('User Time=%d\n',UserTime);
fprintf('CPUBoundTime=%d\n',CPUBoundTime);

fprintf('R=%f\n',GlobalCycle/Rounds);
fprintf('U=%f%%\n',(UserTime/GlobalCycle)*100);
fprintf('S=%f\n',GlobalCycle/CPUBoundTime);




⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?