Beispiel #1
0
void test_share()
{
	int prA = vcreate(proc_share1, 100, 250, 25, "share1", 'd');

	resume(prA);

	int prB = vcreate(proc_share2, 100, 250, 25, "share2", 'd');

	resume(prB);
	sleep(15);
}
Beispiel #2
0
int main() {
  int pid1;
  int pid2;

  kprintf("\n1: shared memory\n");
  pid1 = create(proc1_test1, 2000, 20, "proc1_test1", 0, NULL);
  resume(pid1);
  sleep(10);



  kprintf("\n2: vgetmem/vfreemem\n");
  pid1 = vcreate(proc1_test2, 2000, 100, 20, "proc1_test2", 0, NULL);
  kprintf("pid %d has private heap\n", pid1);
  //assert (pid1 != SYSERR);
  resume(pid1);
  sleep(3);


  kprintf("\n3: Frame test\n");
  pid1 = create(proc1_test3, 2000, 20, "proc1_test3", 0, NULL);
  resume(pid1);
  sleep(3);
  return 0;
}
Beispiel #3
0
void test3() {
  int pids[16];
  int mypid;
  int i,j;

  int ret = TPASSED;
  kprintf("\nTest 3: Private heap is exclusive\n");

  for(i=0;i<=15;i++){
    pids[i] = create(proc1_test3, 2000, 20, "proc1_test3", 2, i,&ret);
    if (pids[i] == SYSERR){
      ret = TFAILED;
    }else{
      resume(pids[i]);
    }
  }
  sleep(1);
  mypid = vcreate(proc2_test3, 2000, 100, 20, "proc2_test3", 0, NULL);
  if (mypid != SYSERR)
    ret = TFAILED;

  for(i=0;i<=15;i++){
    kill(pids[i]);
  }
  if (ret != TPASSED)
    kprintf("\tFAILED!\n");
  else
    kprintf("\tPASSED!\n");
}
Beispiel #4
0
void test_new_share()
{
	int prB = vcreate(proc_new_share2, 100, 250, 25, "procB", 'd');

	resume(prB);

}
Beispiel #5
0
proc_new_share2(char c)
{
	char *addr = (char*) 0x50050000;
	bsd_t bs = 6;
	int i = ((unsigned long) addr) >> 12;
	get_bs(bs, 200);
	
	kprintf("\nPROC B: got bs");
	if (xmmap(i, bs, 200) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	else {
		kprintf("\nPROC B: xmmap success\n");
	
	}


	for (i = 0; i < 10; i++) {
		kprintf("\nPROC B: in for loop count %d",i);
		*addr = 'M' + i;
		//kprintf("\n\n in for %s",*addr);
		addr += NBPG;	//increment by one page each time
	}

	int prA = vcreate(proc_new_share1, 100, 100, 25, "procA", 'd');
	resume(prA);

	int prC = vcreate(proc_new_share3, 100, 100, 25, "procC", 'd');
	resume(prC);

	sleep(10);

	addr = (char*) 0x50050000; //1G
	for (i = 0; i < 10; i++) {
		kprintf("\nPROC B: 0x%08x: %c", addr, *addr);
		addr += 4096;       //increment by one page each time
	}

	xmunmap(0x50050000 >> 12);
}
Beispiel #6
0
void privateHeapLoadTest(){
	int i,pid;
	for(i=1; i<40;i++) {
		while(SYSERR == (pid = vcreate(simpleRecursion, 2000, 2, 20, "simpleRec", 1,i)) ) {
			kprintf("Failed to create process at i=%d. Waiting for 10 more sleep cycles..\n",i);
			sleep(10);
		}
		resume(pid);
	}
	kprintf("heap load test PASS.\n");
	return;
}
Beispiel #7
0
int main()
{

	kprintf("\nRuning main() \n\n");
	int i = 0;
	kprintf("&i = %8x, i = %d\n",&i,i);

	int pid1;
	pid1 = vcreate(proc1_test2, 2000, 100, 20, "proc1_test2", 0, NULL);
	resume(pid1);
	return 0;
}
Beispiel #8
0
void test5() {
  int pid1;
  int ret = TPASSED;

  kprintf("\nTest 5: vgetmem/vfreemem\n");
  pid1 = vcreate(proc1_test5, 2000, 100, 20, "proc1_test5", 1, &ret);

  //kprintf("pid %d has private heap\n", pid1);
  resume(pid1);
  sleep(3);
  kill(pid1);
  if (ret != TPASSED)
    kprintf("\tFAILED!\n");
  else
    kprintf("\tPASSED!\n");
}
Beispiel #9
0
void vheap_test() {
    int p1;
    int hsize = 100; // heap size in pages

    kprintf("\nBasic virtual heap test\n");

    // Create a process that is always ready to run at priority 15
    p1 = vcreate(vheaptask, 2000, 20, hsize, "vheaptask", 0, NULL); 

    // Start the task
    kprintf("start vheaptask (pprio 20), then sleep 1s.\n");
    resume(p1);
    sleep(1);
    
    sleep (10);
    kprintf ("Test finished, ....\n");
}
Beispiel #10
0
/*------------------------------------------------------------------------
 *  main  --  user main program
 *------------------------------------------------------------------------
 */
int main() {

    int proc_A, proc_B, process_VA;
    int result;
	kprintf("\n\nHello World, Xinu lives\n\n");
	//srpolicy(FIFO);

	char *addr = (char*) 0x40000000; //1G
	bsd_t bs = 1;

	int i = ((unsigned long) addr) >> 12;	// the ith page

	result = get_bs(bs, 200);
	if(result == SYSERR){
		kprintf("get_bs call failed\n");
		return 0;
	}
	else
		kprintf("main get_bs call result %d\n", result);

	if (xmmap(i, bs, 150) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}

	for (i = 0; i < 10; i++) {
		*addr = 'A' + i;
		addr += NBPG;	//increment by one page each time
	}

	addr = (char*) 0x40000000; //1G
	for (i = 0; i < 10; i++) {
		kprintf("0x%08x: %c\n", addr, *addr);
		addr += 4096;       //increment by one page each time
	}

	proc_B = create(procB,INITSTK,INITPRIO,"procB",INITARGS);
	resume(proc_B);
	process_VA = vcreate(processVA,INITSTK,100,INITPRIO,"processVA",INITARGS);
	resume(process_VA);
	sleep(2);
	xmunmap(0x40000000 >> 12);
	release_bs(bs);
	kprintf("All izz well\n");
	return 0;
}
Beispiel #11
0
void error_test() {
    int p1;
    int rc;
    char *addr = (char*) 0x40000000; //1G
    int hsize = 100; // heap size in pages
    int npages = 20;

    kprintf("\nBasic error tests\n");


    // Tests test case 1
    rc = xmmap(VA2VPNO(addr), 5, npages);
    if (rc == SYSERR) {
    	kprintf("error_test: Test 1 PASS!\n");
    } else {
    	kprintf("error_test: Test 1 FAIL!\n");
    }


    // Create a process that is always ready to run at priority 15
    p1 = vcreate(error_task, 2000, 20, hsize, "error_task", 0, NULL); 
    resume(p1);

    sleep(1);

    npages = get_bs(1, 10);
    if (npages != 10)
    	kprintf("error_test: Test 3A FAIL!\n");
    else
    	kprintf("error_test: Test 3A PASS!\n");

    npages = get_bs(1,20); //<-- get_bs should return 10 here
    if (npages != 10)
    	kprintf("error_test: Test 3B FAIL!\n");
    else
    	kprintf("error_test: Test 3B PASS!\n");

    npages = get_bs(1,5); //<-- get_bs should return 10 here
    if (npages != 10)
    	kprintf("error_test: Test 3C FAIL!\n");
    else
    	kprintf("error_test: Test 3C PASS!\n");

    sleep(1);

}
Beispiel #12
0
void peakLoadTestLaunch(){
	int i, pid[15];

	get_bs(15,128);
	xmmap(0xFFF80,15,128);
//	*(char *)( 0xFFF80*NBPG) = 'P';
	*(char *)( (0xFFF80+127)*NBPG + NBPG -1) = 'L';
	for(i=0;i<15;i++) {
		pid[i] = vcreate(peakLoadTest, 2000, 128, 10, "peakLoadTest", 1,i);
		if(pid[i] == SYSERR) {
			kprintf("Unable to launch virtual mem process. Test FAIL\n");
		}
		resume(pid[i]);
    //sleep(1);
	}
	xmunmap(0xFFF80);
	sleep(100);
  kprintf("Wake Launch\n");
	release_bs(15);
  kprintf("Exit Launch\n");
}
Beispiel #13
0
int main() {

	int pid1;
	int pid2;

	srpolicy(FIFO);

#if 0
	kprintf("\n1: shared memory\n");
	pid1 = create(proc1_test1, 2000, 20, "proc1_test1", 1, "P1");
	resume(pid1);
	sleep(10);
	pid2 = create(proc2_test1, 2000, 20, "proc2_test1", 4, "P2",63,56,"special");
	resume(pid2);
	sleep(10);
#endif

#if 0
	kprintf("\n2: vgetmem/vfreemem\n");
	pid1 = vcreate(memTest, 2000, 2, 20, "memTest", 4,"MT",78,92,"specialMem");
	kprintf("pid %d has private heap\n", pid1);
	ASSERT(pid1 != SYSERR);
	resume(pid1);
	sleep(3);
#endif

#if 0
  sleep(10);
	kprintf("\n3: Heap and Stack Load Test: Many processes with virtual mem, created and destroyed in a loop.\n");
	pid1 = create(privateHeapLoadTest, 2000, 20, "privateHeapLoadTest", 0,NULL);
	if(pid1 == SYSERR) { kprintf("Cannot create process. Test launch FAIL.\n"); }
	resume(pid1);
	sleep(3);
#endif

#if 0
	kprintf("\n4:FIFO test.\n");
	srpolicy(FIFO);
	pid1 = create(fifo_test, 2000, 20, "fifo", 0, NULL);
  resume(pid1);
  sleep(20);
#endif

#if 1
	kprintf("\n4:LRU test.\n");
	srpolicy(LRU);
	kprintf("Current policy : %d\n",grpolicy());
	pid1 = create(lru_test, 2000, 20, "lru", 0, NULL);
  resume(pid1);
  sleep(10);
#endif

#if 0
	kprintf("\n4: Illegal Address Access Test. These 2 processes should get killed.\n");
	pid1 = vcreate(badAccessTest, 2000, 50, 20, "badAccessTest", 0,NULL);
	pid2 = vcreate(badAccessTest, 2000, 50, 20, "badAccessTest", 0,NULL);
	if(pid1 == SYSERR) { kprintf("Cannot create process1. Test launch FAIL.\n"); }
	if(pid2 == SYSERR) { kprintf("Cannot create process2. Test launch FAIL.\n"); }
	resume(pid1);
	sleep(3);
	resume(pid2);
	sleep(3);
	kprintf("\n6: Test Done. Both the processes should have been killed now.\n");
	sleep(60);
#endif

#if 0
	kprintf("\n5: Peak Load Test: All backing stores fully mapped with first and last byte of every page written and tested. BS-15 shared amongst all process.\n");
	pid1 = create(peakLoadTestLaunch, 2000, 20, "peakLoadTestLaunch", 0,NULL);
	if(pid1 == SYSERR) { kprintf("Cannot create process. Test launch FAIL.\n"); }
	resume(pid1);
	sleep(6000);
#endif
  kprintf("=====================Main End============\n");
  return 0;
}
Beispiel #14
0
void test_vcreate_fifo()
{
	int prA = vcreate(proc_vcreate_fifo, 100, 50, 25, "procA", 'C');
	resume(prA);

	bsd_t bs1 = get_free_bs();
	get_bs(bs1, 256);

	bsd_t bs2 = get_free_bs();
	get_bs(bs2, 256);

	bsd_t bs3 = get_free_bs();
	get_bs(bs3, 256);

	bsd_t bs4 = get_free_bs();
	get_bs(bs4, 193);

	if (xmmap(40000, bs1, 256) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	
	if (xmmap(50000, bs2, 256) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	
	if (xmmap(60000, bs3, 256) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	
	if (xmmap(70000, bs4, 193) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}

	int i = 0;
	char *addr = (char *)(40000*NBPG);
	for (i = 0; i < 256; i++) {
		*addr = 500 + i;
		addr += NBPG;	//increment by one page each time
	}
	addr = (char *)(50000*NBPG);
	for (i = 0; i < 256; i++) {
		*addr = 1000 + i;
		addr += NBPG;	//increment by one page each time
	}
	addr = (char *)(60000*NBPG);
	for (i = 0; i < 256; i++) {
		*addr = 1500 + i;
		addr += NBPG;	//increment by one page each time
	}
	addr = (char *)(70000*NBPG);
	for (i = 0; i < 193; i++) {
		*addr = 2000 + i;
		addr += NBPG;	//increment by one page each time
	}

	//create 1 page fault which will result in page replacement of the heap
	bsd_t bs5 = get_free_bs();
	get_bs(bs5, 1);
	if (xmmap(80000, bs5, 1) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	addr = (char *)(80000*NBPG);
	*addr = 'A';

	sleep(10);
}
Beispiel #15
0
void test_vcreate()
{
	int prA = vcreate(proc_vcreate, 100, 50, 25, "procA", 0);
	resume(prA);
}
Beispiel #16
0
void test_sharing_fifo()
{
	int prA = vcreate(proc_share_fifo1, 100, 250, 25, "procA", 'd');
	resume(prA);

	int prB = vcreate(proc_share_fifo2, 100, 250, 25, "procB", 'd');
	resume(prB);

	bsd_t bs1 = get_free_bs();
	get_bs(bs1, 256);

	bsd_t bs2 = get_free_bs();
	get_bs(bs2, 256);

	bsd_t bs3 = get_free_bs();
	get_bs(bs3, 242);

	if (xmmap(40000, bs1, 256) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	
	if (xmmap(50000, bs2, 256) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	
	if (xmmap(60000, bs3, 242) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}

	int i = 0;
	char *addr = (char *)(40000*NBPG);
	for (i = 0; i < 256; i++) {
		*addr = 500 + i;
		addr += NBPG;	//increment by one page each time
	}
	addr = (char *)(50000*NBPG);
	for (i = 0; i < 256; i++) {
		*addr = 1000 + i;
		addr += NBPG;	//increment by one page each time
	}
	addr = (char *)(60000*NBPG);
	for (i = 0; i < 242; i++) {
		*addr = 1500 + i;
		addr += NBPG;	//increment by one page each time
	}

	//generating a page fault
	bsd_t bs5 = get_free_bs();
	get_bs(bs5, 1);
	if (xmmap(30000, bs5, 1) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	addr = (char *)(30000*NBPG);
	*addr = 'C';

	sleep(20);

	xmunmap(40000);
	xmunmap(50000);
	xmunmap(60000);
	xmunmap(30000);
}
Beispiel #17
0
void test_fifo()
{
	char *addr = (char*) 0x40000000; //1G
	bsd_t bs = get_free_bs();

	int i = ((unsigned long) addr) >> 12;	// the ith page

	kprintf("\n\nTesting FIFO %d\n\n", i);
	
	get_bs(bs, 250);

	if (xmmap(i, bs, 250) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	else {
	
	}
	for (i = 0; i < 250; i++) {
		*addr = i+0;
		addr += NBPG;	//increment by one page each time
	}

	int prA = vcreate(proc1, 100, 250, 25, "proc A", 'd');

	resume(prA);

	int prB = vcreate(proc2, 100, 250, 25, "proc B", 'd');

	resume(prB);

	char *addr2 = (char*) 0x50000000;
	bsd_t bs2 = get_free_bs();
	int j = ((unsigned long) addr2) >> 12;
	if (xmmap(j, bs2, 250) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	for (i = 0; i < 250; i++) {
		*addr2 = i+1500;
		addr2 += NBPG;	//increment by one page each time
	}
	
	char *addr3 = (char*) 0x60000000;
	bsd_t bs3 = get_free_bs();
	int k = ((unsigned long) addr3) >> 12;
	if (xmmap(k, bs3, 100) == SYSERR) {
		kprintf("xmmap call failed\n");
		return 0;
	}
	
	char *access = (char *) 0x40000000;
	*access = 'P';
	kprintf("\nAccessing the first memory location to avoid page replacement in aging %c %lu\n",*access, (unsigned long)access);

	for (i = 0; i < 100; i++) {
		*addr3 = i+2000;
		addr3 += NBPG;	//increment by one page each time
	}

	addr = (char*) 0x40000000;
	kprintf("\nAccessing first ever page here %d\n", *addr);

	xmunmap(0x40000000 >> 12);
	xmunmap(0x50000000 >> 12);
	xmunmap(0x60000000 >> 12);
	release_bs(bs);
	release_bs(bs2);
	release_bs(bs3);
	sleep(10);
}