Example #1
0
int main(int argc , char ** argv)
{
  int i,j ;     	/* loop index */
  int scr_sem; 		/* id of screen semaphore */
  int time; 		/* current and start time */
  int ping,pong;	/* id of semaphores to sync processes b & c */

  time = Get_Time_Of_Day();
  scr_sem = Create_Semaphore ("screen" , 1) ;   /* register for screen use */
  ping = Create_Semaphore ("ping" , 1) ;   
  pong = Create_Semaphore ("pong" , 0) ;  

  for (i=0; i < 5; i++) {
       P(pong);
       for (j=0; j < 35000; j++);
       Print("Ping\n ");
       V(ping);
  }

  time = Get_Time_Of_Day() - time;
  P (scr_sem) ;
  Print ("Process Ping is done at time: %d\n", time) ;
  V(scr_sem);

  Destroy_Semaphore(pong);
  Destroy_Semaphore(ping);
  Destroy_Semaphore(scr_sem);

  return (0);

}
Example #2
0
int main() {
    int x = 2;
    Get_NewTOD(&x);
    Print("%d\n", x);
    int y = Get_Time_Of_Day();
    Print("%d\n", y);
    return 0;
}
Example #3
0
int main(int argc, char **argv)
{
  int i, j ;     	/* loop index */
  int scr_sem;		/* id of screen semaphore */
  int now, start, elapsed; 		

  start = Get_Time_Of_Day();
  scr_sem = Create_Semaphore ("screen" , 1) ;   /* register for screen use */

  for (i=0; i < 200; i++) {
      for (j=0 ; j < 10000 ; j++) ;
      now = Get_Time_Of_Day();
  }
  elapsed = Get_Time_Of_Day() - start;
  P (scr_sem) ;
  Print("Process Long is done at time: %d\n", elapsed) ;
  V(scr_sem);


  return 0;
}
Example #4
0
int main(int argc , char ** argv)
{
  int i,j ;     	/* loop index */
  int start_sem;
  int scr_sem; 		/* id of screen semaphore */
  int time; 		/* current and start time */
  int ping,pong;	/* id of semaphores to sync processes b & c */

  time = Get_Time_Of_Day();
  start_sem = Create_Semaphore ("start" , 1);
  scr_sem = Create_Semaphore ("screen" , 1) ;   /* register for screen use */
  ping = Create_Semaphore ("ping" , 1) ;    
  pong = Create_Semaphore ("pong" , 0) ;   

  P (start_sem) ;
  V (start_sem) ;
  
  for (i=0; i < 50; i++) {
       P(ping);
       for (j=0; j < 35; j++);
     P(scr_sem);
	   Set_Attr(ATTRIB(BLACK, BLUE|BRIGHT));
	   Print("Pong");
     Set_Attr(ATTRIB(BLACK, GRAY));
     V(scr_sem);
     V(pong);
  }

  time = Get_Time_Of_Day() - time;
  P(scr_sem) ;
  Print ("\nProcess #Pong is done at time: %d\n", time) ;
  V(scr_sem);





  return (0);
}
Example #5
0
int main(int argc, char **argv) {
    int policy = -1;
    int start;
    int elapsed;
    int scr_sem;                /* sid of screen semaphore */
    int id1, id2, id3;          /* ID of child process */

    if(argc == 2) {
        if(!strcmp(argv[1], "rr")) {
            policy = 0;
        } else if(!strcmp(argv[1], "mys")) {
            policy = 1;
        } else {
            Print("usage: %s [rr|mys]\n", argv[0]);
            Exit(1);
        }
        Set_Scheduling_Policy(policy, 20);
    } else {
        Print("usage: %s [rr|mys]\n", argv[0]);
        Exit(1);
    }

    start = Get_Time_Of_Day();
    scr_sem = Open_Semaphore("screen", 1);

    P(scr_sem);
    Print("************* Start Workload Generator *********\n");
    V(scr_sem);

    id1 = Spawn_Program("/c/long.exe", "/c/long.exe", 0);
    P(scr_sem);
    Print("Process Long has been created with ID = %d\n", id1);
    V(scr_sem);


    id2 = Spawn_Program("/c/long.exe", "/c/long.exe", 0);

    P(scr_sem);
    Print("Process Long #1 has been created with ID = %d\n", id2);
    V(scr_sem);

#ifdef notdef
    id2 = Spawn_Program("/c/ping.exe", "/c/ping.exe", 0);

    P(scr_sem);
    Print("Process Ping has been created with ID = %d\n", id2);
    V(scr_sem);

    id3 = Spawn_Program("/c/pong.exe", "/c/pong.exe", 0);
    P(scr_sem);
    Print("Process Pong has been created with ID = %d\n", id3);
    V(scr_sem);
#endif

    Wait(id1);
    Wait(id2);
    // Wait(id3);

    elapsed = Get_Time_Of_Day() - start;
    Print("\nTests Completed at %d\n", elapsed);
    return 0;
}
Example #6
0
 * enrolled in similar operating systems courses the University of Maryland's CMSC412 course.
 */
#include <conio.h>
#include <process.h>
#include <sched.h>
#include <sema.h>
#include <string.h>

int main(int argc __attribute__ ((unused)), char **argv
         __attribute__ ((unused))) {
    int i, j;                   /* loop index */
    int scr_sem;                /* id of screen semaphore */
    int time;                   /* current and start time */
    int ping, pong;             /* id of semaphores to sync processes b & c */

    time = Get_Time_Of_Day();
    scr_sem = Open_Semaphore("screen", 1);      /* register for screen use */
    ping = Open_Semaphore("ping", 1);
    pong = Open_Semaphore("pong", 0);

    for (i = 0; i < 5; i++) {
        P(ping);

        P(scr_sem);
        Print("Pong\n");
        V(scr_sem);

        for (j = 0; j < 35; j++);
        V(pong);
    }