/********************************************************************** Project 2: Multiprogramming Part I SECTION 0102 By: Jeff Hollingsworth e-mail: hollings@cs.umd.edu File: proc2.c Created on: 3/6/1996 Contents: User Processes to be run concurrently 1. Init() : Initial process, creates other ones & terminates 2..4 Long() , Ping() , and Pong() are three examplar processes that are to be run concurently. Long() is a CPU intensive job, while Ping() and Pong() bounce back between one another. 5. Wait() : busy wait for a key to be pressed Simon Hawkin 03/16/1998 - Added progress monitoring output in Long(). [2] An enclosed test ("proc2.c", or "encl2.c"). **********************************************************************/ #include "user412.h" #include "cmsc412.h" #if !defined (NULL) #define NULL 0 #endif #if defined (DELAY) #undef DELAY #endif #define DELAY 500 int Long ( int , char ** ) ; int Ping ( int , char ** ) ; int Pong ( int , char ** ) ; void Wait( int ) ; /*-------------------------------------------------------------------*/ /* ignore unused paramters for the processes */ #pragma warn -par int Init( int argc , char ** argv ) { int i , /* loop index */ scr_sem,/* sid of screen semaphore */ id , /* ID of child process */ count; /* child process's argc */ char * argument[10] ; /* pointer to a maximum of 10 arguments */ scr_sem = Create_semaphore ( "screen" , 1 ) ; P ( scr_sem ) ; Cprintf ("\nTest 2, delay=%d\n", DELAY ); Cprintf ("\n*************This is the init procedure*********\n"); Cprintf ("I have %2d arguments. They are \n" , argc ); for ( i=0 ; i