Esempio n. 1
0
	/* Test to make sure a bad index will be blocked from reaching the system call */
	void destroy_CV_Bad_Index_Test(){
		Write("Testing Destroy CV on a negative index\n", sizeof("Testing Destroy CV on a negative index\n"), ConsoleOutput);
		DestroyCV(-1);
		Write("Testing Destroy CV on index of 12 (Larger than next index)\n", sizeof("Testing Destroy CV on index of 12 (Larger than next index)\n"), ConsoleOutput);
		DestroyCV(12);
		Write("Testing Destroy CV on index 11\n", sizeof("Testing Destroy CV on index 11\n"), ConsoleOutput);
		DestroyCV(11);
	}
Esempio n. 2
0
void t3_t1(){
    indexcheck1=CreateCV("def", 1);
    indexcheck2=DestroyCV(indexcheck1+100);
    indexcheck3= CreateCV("abc", -1);
    indexcheck4=DestroyCV(-100);
    if (indexcheck1==-1 && indexcheck2==-1 && indexcheck3==-1 && indexcheck4==-1){
        Write("passed: create/destroyCV validates input\n", sizeof("passed: create/destroyCV validates input\n"), 1);
    }
    else{
        Write("failed: create/destroyCV validates input\n", sizeof("failed: create/destroyCV validates input\n"), 1);
    }
}
Esempio n. 3
0
int main()
{

	lock = CreateLock("lock");
	cv2 = CreateCV("cv2");
	
	AcquireLock("lock");

	SignalCV("lock","cv2");

	Print("Client 3 will now destroy CV...",-1,-1,-1);
	
	DestroyCV("cv2");
	
	for (i=0; i<9; i++)
		Print("\n",-1,-1,-1);


	ReleaseLock("lock");

	AcquireLock("lock");	
	
	WaitCV("lock","cv2");
	
	Print("Client 3: This prints as CV has been destroyed...",-1,-1,-1);

	ReleaseLock("lock");

	Exit(0);

}
Esempio n. 4
0
/* Starts executing here */
int main() {
	Write("Running test of Exec syscall.\n", 30, ConsoleOutput);
  Fork((void *)forkThread1);
  Fork((void *)forkThread2);
	Write("Exec finished forking threads, now trying to create a lock\n", sizeof("Exec finished forking threads, now trying to create a lock\n"), ConsoleOutput);
	lock_1 = CreateLock();
	Print("lock_1 position created at %i\n", lock_1, -1, -1);
	Write("Exec created a lock!\n", sizeof("Exec created a lock!\n"), ConsoleOutput);
	
	/* Testing to make sure none of the syscalls can be called from the wrong process after being created by the 1st process */
	/* Lock */
	Print("Trying to destroy lock 5 from wrong process\n", -1, -1, -1);
	DestroyLock(5);
	/* CV */
	Print("Trying to destroy cv 5 from wrong process\n", -1, -1, -1);
	DestroyCV(5);
	/* Acquire */
	Print("Trying to acquire lock 6 from wrong process\n", -1, -1, -1);
	Acquire(6);
	/* Release */
	Print("Trying to release lock 6 from wrong process\n", -1, -1, -1);
	Release(6);
	/* Wait */
	Print("Trying to wait on cv 6 from wrong process\n", -1, -1, -1);
	Wait(6, 6);
	/* Signal */
	Print("Trying to signal on cv 6 from wrong process\n", -1, -1, -1);
	Signal(6, 6);
	/* Broadcast */
	Print("Trying to broadcast on cv 6 from wrong process\n", -1, -1, -1);
	Broadcast(6, 6);
	
	/* Leave new process after tests */
	Exit(0);
}
Esempio n. 5
0
void t6_t1() {
    /*2nd to acquire lock*/
    test=AcquireLock(indexcheck1);
    test=Wait(LockIndex1, CVIndex1);
    Write("2\n", sizeof("2\n"), 1);
    test=ReleaseLock(indexcheck1);
    test=DestroyLock(indexcheck1);
    test=DestroyCV(CVIndex1);
    Exit(0);
}
Esempio n. 6
0
int main() {
  Write("Test 5 creates lock and cv\n", sizeof("Test 5 creates lock and cv\n"), ConsoleOutput);
  lock = CreateLock("lock", sizeof("lock"));
  cv = CreateCV("cv", sizeof("cv"));

  for (i = 0; i < 50000; i++) {
    Yield();
  }

  Write("Test 5 destroys lock and cv\n", sizeof("Test 5 destroys lock and cv\n"), ConsoleOutput);
  DestroyLock(lock);
  DestroyCV(cv);
}
Esempio n. 7
0
int main()
{

	cv = CreateCV("cv_1");
	lock = CreateLock("lock1");


	AcquireLock("lock1");
	SignalCV("lock1","cv_1");
	ReleaseLock("lock1");

	DestroyCV("cv_1");
	
	AcquireLock("lock1");
	
	WaitCV("lock1","cv_1");
	Print("This prints as CV has been destroyed so no wait occurs..",-1,-1,-1);
	ReleaseLock("lock1");

	Exit(0);
}
Esempio n. 8
0
int main()
{
	i=CreateLock("Lock 0");
	Print("Lock_%d created...\n",i,-1,-1);
	
	for(loop = 0; loop < 1000 ;loop++)
		{
			j=CreateCV("CV j");
			j2=CreateCV("CV j2");

			AcquireLock(i);
			WaitCV(i,j2+1);
			Print("This doesnt print after we get errors for going out of threads..\n",-1,-1,-1);
			Fork(test,"Fork 1");
			
			WaitCV(i,j);
			Print("main is now awake\n",-1,-1,-1);
			DestroyCV(j);/*Only one of the locks is always deleted*/
		}

}
Esempio n. 9
0
	/* Test to make sure that a active cv will not be deleted, but marked for deletion */
	destroy_CV_Thread_Using_CV(){
		Write("Testing Destroy CV on waiting cv_9\n", sizeof("Testing Destroy CV on waiting cv_9\n"), ConsoleOutput);
		DestroyCV(cv_9);
	}
Esempio n. 10
0
	/* Test to make sure a already deleted cv will be blocked from reaching the system call  */
	void destroy_CV_Already_Deleted(){
		Write("Testing Destroy CV on already deleted CV, cv_1\n", sizeof("Testing Destroy CV on already deleted CV, cv_1\n"), ConsoleOutput);
		DestroyCV(cv_1);
	}
Esempio n. 11
0
	/* Destroy the cv created in the default test */
	void destroy_CV_Test(){
		Write("Testing Destroy CV. Destroying cv_1\n", sizeof("Testing Destroy CV. Destroying cv_1\n"), ConsoleOutput);
		DestroyCV(cv_1);
	}