当前位置: 首页>>代码示例>>C++>>正文


C++ USLOSS_Console函数代码示例

本文整理汇总了C++中USLOSS_Console函数的典型用法代码示例。如果您正苦于以下问题:C++ USLOSS_Console函数的具体用法?C++ USLOSS_Console怎么用?C++ USLOSS_Console使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了USLOSS_Console函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: P2_Startup

int P2_Startup(void *arg){
	
	USLOSS_Console(" \n---------Starting Test 9 ----------\n");
		
	sem = P1_SemCreate(0);  
	
	int childpid1, child_status1, exit_childpid1;
	int childpid2, child_status2, exit_childpid2;


	childpid1 = P1_Fork("child_p", child_p, NULL, USLOSS_MIN_STACK * 4, 2);
  	USLOSS_Console("Child PID created %d \n", childpid1);	

	childpid2 = P1_Fork("killer", killer, &childpid1, USLOSS_MIN_STACK * 4, 3);
  	USLOSS_Console("Child PID created %d \n", childpid2);

	exit_childpid1 = P1_Join(&child_status1);	

	exit_childpid2 = P1_Join(&child_status2);


	USLOSS_Console("end first %d (should be %d)        status %d (should be 444)\nend second %d (should be %d)        status %d (should be -4)\n",
			exit_childpid1,childpid1,child_status1,exit_childpid2,childpid2, child_status2);
		

	USLOSS_Console(" ---------Ending Test 9 ----------\n");
	return 0;
}
开发者ID:TannerKoch,项目名称:CS452,代码行数:28,代码来源:test9.c

示例2: clockHandler2

static void clockHandler2(int dev, void *arg) {
    long unit = (long) arg;
    int clockResult;

    // check if dispatcher should be called
    if (readCurStartTime() >= 80000) {
        timeSlice();
    }

    // inc that a clock interrupt happened
    clockTicks++;

    USLOSS_DeviceInput(dev, unit, &clockResult);

    
    // every fith interrupt do a conditional send to its mailbox
    if (clockTicks % 5 == 0) {

        if (debugflag2 && DEBUG2) {
            USLOSS_Console("clockHandler2: sending message %s to mbox %d\n", clockResult, clockBox.mboxID);
        }

        int sendResult = MboxCondSend(clockBox.mboxID, &clockResult, sizeof(clockResult));

        if (debugflag2 && DEBUG2) {
            USLOSS_Console("clockHandler2: send returned %d\n", sendResult);
            USLOSS_Halt(1);
        }
    }
}
开发者ID:awewing,项目名称:usloss,代码行数:30,代码来源:phase2.c

示例3: terminalHandler

static void terminalHandler(int dev, void *arg) {

    long unit = (long) arg;

    if (debugflag2 && DEBUG2) {
        USLOSS_Console("terminalHandler(): dev = %d\n", dev);
        USLOSS_Console("terminalHandler(): unit = %d\n", unit);
    }
    int termResult;

    // check for valid values
    if (dev != USLOSS_TERM_DEV || unit < 0 || unit > USLOSS_TERM_UNITS) {
        USLOSS_Console("termHandler(): Bad values\n");
        USLOSS_Halt(1);
    }

    // make sure our box still exists
    if (termBoxes[unit].mboxID == -1) {
        USLOSS_Console("Term mailbox does not exist, unit\n");
        USLOSS_Halt(1); // might need to reutn instead
    }

    int result = USLOSS_DeviceInput(USLOSS_TERM_DEV, unit, &termResult);

    // if (debugflag2 && DEBUG2) {
    //     USLOSS_Console("terminalHandler(): sending now from dev %d to mbox %d value %s\n", dev, termBoxes[unit].mboxID, termResult);
    // }
    MboxCondSend(termBoxes[unit].mboxID, &termResult, sizeof(termResult));

    if (result != USLOSS_DEV_OK) {
        USLOSS_Console("termHandler(): USLOSS_DeviceInput is not ok.\n");
        USLOSS_Halt(1);
    }
}
开发者ID:awewing,项目名称:usloss,代码行数:34,代码来源:phase2.c

示例4: start4

int start4(char *arg)
{
   int  pid, status, i;
   char buf[12];
   char child_buf[12];

   USLOSS_Console("start4(): Spawn eight children.  \n");
   USLOSS_Console("          4 write 5 lines to a diff terminal.\n");
   USLOSS_Console("          4 read 5 lines to a diff terminal.\n");

   for (i = 0; i < 4; i++) {
      sprintf(buf, "%d", i);
      sprintf(child_buf, "Child%d", i);
      status = Spawn(child_buf, Child1, buf, USLOSS_MIN_STACK,2, &pid);
      sprintf(child_buf, "Child%d", i+4);
      assert(status == 0);
      status = Spawn(child_buf, Child2, buf, USLOSS_MIN_STACK,2, &pid);
      assert(status == 0);
   }

   for (i = 0; i < 8; i++) {
      Wait(&pid, &status);
      //assert(status == 0);
   }

   USLOSS_Console("start4(): done.\n");
   Terminate(1);
   return 0;
} /* start4 */
开发者ID:jasonknott,项目名称:CSC452,代码行数:29,代码来源:test19.c

示例5: waitDevice

int waitDevice(int type, int unit, int *status) {
    mailbox *mbox;

    switch (type) {
        case USLOSS_CLOCK_DEV :
            mbox = &clockBox;
            break;
        case USLOSS_DISK_INT :
            mbox = &diskBoxes[unit];
            break;
        case USLOSS_TERM_INT :
            mbox = &termBoxes[unit];
            break;
    }

    if (debugflag2 && DEBUG2) {
        USLOSS_Console("waitDevice(): receiving from %d\n", mbox->mboxID);
    }

    //notify p1.c that there is another process waiting on a device, then receive/block
    addProcess();
    MboxReceive(mbox->mboxID, status, sizeof(long));
    releaseProcess();

    if (debugflag2 && DEBUG2) {
        USLOSS_Console("waitDevice(): received %s from mailbox %d\n", status, mbox->mboxID);
    }

    if (isZapped()) {
        return -1;
    }

    return 0;
}
开发者ID:awewing,项目名称:usloss,代码行数:34,代码来源:phase2.c

示例6: P2_Startup

int P2_Startup(void *notused) 
{
    USLOSS_Console("P2_Startup\n");
    P1_Fork("P3_Startup", P3_Startup, NULL, 4 *  USLOSS_MIN_STACK, 4);
    USLOSS_Console("P2_Finished\n");
    return 0;
}
开发者ID:classless-pleb,项目名称:452-phase1-partA,代码行数:7,代码来源:test18.c

示例7: Child1

int Child1(char *arg)
{
   int term = atoi(arg);
   char buf[MAXLINE] = "";
   int read_length;
   int i;

   USLOSS_Console("Child%d(): start\n", term);

   for (i = 0; i< 5; i++){
      if (TermRead(buf, MAXLINE, term, &read_length) < 0) {
         USLOSS_Console("ERROR: ReadTeam\n");
         return -1;
      }
      else {
         buf[read_length] = '\0';
         USLOSS_Console("Child%d(): read %s", term, buf);
      }
   }

   USLOSS_Console("Child%d(): done\n", term);

   Terminate(0);
   return 0;
} /* Child 1 */
开发者ID:jasonknott,项目名称:CSC452,代码行数:25,代码来源:test19.c

示例8: P4_Startup

int P4_Startup(void *notused) {
 //   P1_DumpProcesses();
    USLOSS_Console("P4_Startup\n");
    P1_Fork("P6_Startup", P6_Startup, NULL, 4 *  USLOSS_MIN_STACK, 1);
    USLOSS_Console("P4_Finished\n");
    return 0;
}
开发者ID:classless-pleb,项目名称:452-phase1-partA,代码行数:7,代码来源:test16b.c

示例9: P2_Startup

int P2_Startup(void *notused) 
{
    int pid;
    int state;
    int status = 0;

    USLOSS_Console("P2_Startup\n");
    pid = P1_Fork("Child", Child, NULL, USLOSS_MIN_STACK, 3);
    if (pid < 0) {
        USLOSS_Console("Unable to fork child: %d\n", pid);
        status = 1;
    } else {
        /*
         * Child runs at priority 3, which is lower than ours. Part A is
         * run-to-completion, so we should continue to run while the 
         * child waits.
         */

        state = P1_GetState(pid);
        if (state != 1) { // child should be ready
            USLOSS_Console("Child is in invalid state: %d\n", state);
            status = 1;
        }
    }
    return status;
}
开发者ID:UA-CSC452,项目名称:phase1-starter,代码行数:26,代码来源:test1.c

示例10: P3_Startup

int P3_Startup(void *arg) {
	USLOSS_Console(
			"Starting test of creating a simple mailbox with no problems\n");
	int id = -1;
	int result = Sys_MboxCreate(1, 500, &id);
	assert(result == 0);
	assert(id >= 0);
	USLOSS_Console("Created the mailbox\n");
	int size = 7;
	char *input = "hello!";
	result = Sys_MboxSend(-5, input, &size);
	assert(result == -1);
	size = 7;
	result = Sys_MboxSend(5000, input, &size);
	assert(result == -1);
	size = 501;
	result = Sys_MboxSend(id, input, &size);
	assert(result == -1);
	size = -1;
	result = Sys_MboxSend(id, input, &size);
	assert(result == -1);
	size = 501;
	result = Sys_MboxSend(-50, input, &size);
	assert(result == -1);

	USLOSS_Console("You passed all the tests! Treat yourself to a cookie!\n");
	return 7;
}
开发者ID:TannerKoch,项目名称:CS452,代码行数:28,代码来源:sendOnMailboxWithInvalidParamsTest.c

示例11: start4

int start4(char *arg)
{
    int result;
    int status;

    USLOSS_Console("start4(): Writing data to 3 disk sectors, wrapping ");
    USLOSS_Console("to next track\n");

    USLOSS_Console("\nstart4(): Disk 0:\n");
    strcpy(&sectors[0 * 512], "This is a test\n");
    strcpy(&sectors[1 * 512], "Does it work?\n");
    strcpy(&sectors[2 * 512], "One last chance\n");
    result = DiskWrite((char *) sectors, 0, 4, 15, 3, &status);
    assert(result == 0);
    result = DiskRead((char *) copy, 0, 4, 15, 3, &status);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[0*512]);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[1*512]);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[2*512]);

    USLOSS_Console("\nstart4(): Disk 1:\n");
    strcpy(&sectors[0 * 512], "This is a test\n");
    strcpy(&sectors[1 * 512], "Does it work?\n");
    strcpy(&sectors[2 * 512], "One last chance\n");
    result = DiskWrite((char *) sectors, 1, 4, 15, 3, &status);
    assert(result == 0);
    result = DiskRead((char *) copy, 1, 4, 15, 3, &status);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[0*512]);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[1*512]);
    USLOSS_Console("start4(): Read from disk: %s\n", &copy[2*512]);

    Terminate(24);
    return 0;
}
开发者ID:jasonknott,项目名称:CSC452,代码行数:33,代码来源:test12.c

示例12: Child

int Child(void *arg) {
    int     pid;
    int     state;
    int     status = 0;
    USLOSS_Console("Child\n");
    P1_DumpProcesses();
	pid = P1_Fork("Grandchild", Grandchild, NULL, USLOSS_MIN_STACK, 2);
    if (pid < 0) {
        USLOSS_Console("Unable to fork child: %d\n", pid);
        status = 1;
    } else {
        /*
         * Grandchild runs at priority 2, which is higher than ours. Part A is
         * run-to-completion, the grandchild should already have quit before
         * we get here.
         */
//	USLOSS_Console("Grandchild pid : %d,State=%d\n", pid,P1_GetState(pid));
        state = P1_GetState(pid);
        if (state != 3) { // grandchild should have quit
            USLOSS_Console("Grandchild is in invalid state: %d\n", state);
            status = 1;
        }
    }
    return status;
}
开发者ID:abs-sent,项目名称:teamAwesome,代码行数:25,代码来源:test2.c

示例13: start4

int start4(char *arg)
{
   int  pid, status, i;
   char buf[12];
   char name[] = "ChildS";

   USLOSS_Console("start4(): Spawning 5 children to sleep\n");
   for (i = 0; i < 5; i++) {
      sprintf(buf, "%d", i);
      name[5] = buf[0];
      status = Spawn(name, ChildS, buf, USLOSS_MIN_STACK,2, &pid);
   }

   USLOSS_Console("start4(): Spawning 2 children to termfuncs\n");
   status = Spawn("ChildTR", ChildTR, NULL, USLOSS_MIN_STACK,2, &pid);
   status = Spawn("ChildTW", ChildTW, NULL, USLOSS_MIN_STACK,2, &pid);

   USLOSS_Console("start4(): Spawning 4 children to diskfuncs\n");
   status = Spawn("ChildDW0", ChildDW0, NULL, USLOSS_MIN_STACK,2, &pid);
   status = Spawn("ChildDW1", ChildDW1, NULL, USLOSS_MIN_STACK,2, &pid);
   status = Spawn("ChildDR0", ChildDR0, NULL, USLOSS_MIN_STACK,4, &pid);
   status = Spawn("ChildDR1", ChildDR1, NULL, USLOSS_MIN_STACK,4, &pid);

   for (i = 0; i < 11; i++) {
      Wait(&pid, &status);
   }

   USLOSS_Console("start4(): done.\n");
   Terminate(1);
   return 0;
} /* start4 */
开发者ID:jasonknott,项目名称:CSC452,代码行数:31,代码来源:test22.c

示例14: ChildTR

int ChildTR(char *arg)
{
   char buf[80] = "";
   int read_length;
   int i;

   USLOSS_Console("ChildTR(): start\n");

   for (i=0; i<4; i++) {
      if (TermRead(buf, 80, i, &read_length) < 0) {
         USLOSS_Console("ChildTR(): ERROR: ReadTerm\n");
         return -1;
      }
      else {
         USLOSS_Console("ChildTR(): terminal %d, read_length = %d\n", i, read_length);
         buf[read_length] = '\0';
         USLOSS_Console("ChildTR(): read from term%d: read %s", i, buf);
      }
   }

   USLOSS_Console("ChildTR(): done\n");

   Terminate(0);
   return 0;
} /* ChildTR */
开发者ID:jasonknott,项目名称:CSC452,代码行数:25,代码来源:test22.c

示例15: TermRead

int TermRead (char *buffer, int bufferSize, int unitID,
                       int *numCharsRead){
	
	//check for illegal arguments
	if (buffer == 0 || bufferSize <= 0 || unitID < 0){
	 	if (debugflaglib4)
			USLOSS_Console("TermRead(): invalid arguments! returning\n");
		return -1;
	}

	 //build sysarg structure to pass to the syscall vec
	systemArgs sysArg;

	CHECKMODE;
	sysArg.number = SYS_TERMREAD;
	sysArg.arg1 = buffer;
	sysArg.arg2 = (void *) ( (long) bufferSize);
	sysArg.arg3 = (void *) ( (long) unitID);

	if (debugflaglib4)
		USLOSS_Console("TermRead(): sysarg built, calling sysvec function\n");
	USLOSS_Syscall(&sysArg);

	int bytesRead = (int ) ((void*) sysArg.arg2);
	*numCharsRead = bytesRead;

	//return (int ) ((void*) sysArg.arg2);

	return 0;
}
开发者ID:JFitzMan,项目名称:UslossPhase4,代码行数:30,代码来源:libuser4.c


注:本文中的USLOSS_Console函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。