Advertisement
mhdew

simulation of telephone system

Jul 4th, 2020
1,680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. input: list of "new calls"
  2.  
  3. import "new call" from queue
  4. update "arrival time" of "new call"
  5. if (any "end" of "call in progress" <= "arrival time" of "new call"){
  6.     // process the call from "call in progress"
  7.     turn off the flag of the sources of ended call in "lines" list;
  8.     update "used" in "links";
  9.     update "clock";
  10.     remove the ended call from "call in progress";
  11.     update "processed" & "completed" in "call counter";
  12. }
  13. else{
  14.     if (any one source of "new call" is connected with another source in "call in progress"){
  15.         // add the new call to busy
  16.         update "clock";
  17.         update "processed" & "busy" in "call counter";
  18.         import "new call" from queue;
  19.         update "arrival time" of "new call";
  20.     }
  21.     else if (all the rooms are full in "call in progress"){
  22.         // add the new call to blocked
  23.         update "clock";
  24.         update "processed" & "blocked" in "call counter";
  25.         import "new call" from queue;
  26.         update "arrival time" of "new call";
  27.     }
  28.     else{
  29.         // add the new call to "call in progress"
  30.         turn on the flag of the sources of "new call" in "lines" list;
  31.         update "used" in "links";
  32.         update "clock";
  33.         add the call to "call in progress";
  34.         import "new call" from queue;
  35.         update "arrival time" of "new call";
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement