コード例 #1
0
int body()
{ 
	char c;

	printf("proc %d starts from body()\n", running->pid);

	while(1)
	{
		printf("-----------------------------------------\n");
		//prints the list of procs that are initializedd and free
		printf("freelist = ");
		printQueue(freeList);// optional: show the freeList

		//print ready queue which are procs that are ready
		printf("readyQueue = ");
		printQueue(readyQueue); // show the readyQueue

		//printf("sleepList = ");
		//printQueue(sleepList);

		printf("-----------------------------------------\n");

		printf("proc %d running: parent=%d\n",running->pid,running->ppid);
		printf("enter a char [s|f|q z|a|w] : ");

		c = getc();
		printf("%c\n", c);

		switch(c)
		{
			case 'f': //fork a child off of the current process
				do_kfork();
				break;
			case 's': //switch to next process in ready queue
				do_tswitch();
				break;
			case 'q': //zombie the current process
				do_exit();
				break;
			case 'z': //running PROC go to sleep on an event value
				do_sleep();
				break;
			case 'a': //wakeup all PROCs sleeping on event
				do_wakeup();
				break;
			case 'w': //to wait for a ZOMBIE child
				do_wait();
				break;
		}
	}
}
コード例 #2
0
ファイル: t.c プロジェクト: tymicruz/CuatroSeisZero
int body()
{ 
   char c;
        color = running->pid + 7;

   printf("\nproc %d resumes to body()\n", running->pid);
   while(1){
     color = running->pid + 7;
     printQueue(freeList, "freeList");
     printQueue(readyQueue, "readyQueue");

     printf("proc %d running : \nenter a key (s|q|f | z|a|w): ", running->pid);
     c = getc();
	printf("%c\n", c);
     switch(c)
     {
     	case 's':
     		tswitch();
     	break;

     	case 'q':
     		do_exit();
     	break;

     	case 'f':
     		do_kfork();
     	break;
     	case 'z':
     		//printf("sleep\n");
     		do_sleep();
     	//go to sleep on an even
     	break;
     	case 'a':
     		//printf("wake up\n");
     		do_wakeup();
     	//wakeup all procs sleeping on event
     	break;
     	case 'w':
     		//printf("wait\n");
     		do_wait();
     	//wait for a ZOMBIE child
     	break;
     }

     
     //tswitch();
   }
}
コード例 #3
0
ファイル: t.c プロジェクト: shank8/CS460
int body()
{  char c;
   while(1){
      printf("\n\n\n");
     ps();
      printf("I am Proc %d in body()\n", running->pid); 
      printf("Input a char : [s|q|f|z|a|w]: ");
       c=getc();
     
       switch(c){
            case 's': tswitch(); break;
            case 'q': do_exit();   break;
            case 'f': kfork();   break;
            case 'z': do_sleep();   break;
            case 'a': do_wakeup();  break;
            case 'w': do_wait();    break;
            default :            break;
       }
   }
}
コード例 #4
0
ファイル: t.c プロジェクト: JohnnySmith1/Cpts-349-Work
int body()
{
	char c;
	printf("proc %d resumes to body()\n", running->pid);
	while(1)
	{
		printf("-----------------------------------------\n");
		//print freeList;
		printf("Free List:\n");
		printQueue(freeList);
		// print readyQueue;
		printf("Ready Queue:\n");
		printQueue(readyQueue);
		// print sleepList;
		printf("Sleep List:\n");
		printSleepQueue(sleepList);
		printf("-----------------------------------------\n");

		printf("proc %d[%d] running: parent=%d\n",
			running->pid, running->priority, running->ppid);

		printf("type a char [s|f|q| p|z|a| w ] : ");
		c = getc(); 
		printf("%c\n", c);

		switch(c){
			case 's' : do_tswitch();   break;
			case 'f' : do_kfork();     break;
			case 'q' : do_exit();      break; 
			case 'p' : do_ps();        break; 
			case 'z' : do_sleep();     break; 
			case 'a' : do_wakeup();    break; 
			case 'w' : do_wait();      break;
		}
	}
}