Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
int P2_Startup(void *notused) 
{
    USLOSS_Console("P2_Startup\n");
      
    if (P1_GetPID() != 1) {
        USLOSS_Console("Fail: id does not equal 1");
    }
 
    if (P1_GetState(1) != 0) {
        USLOSS_Console("Fail: state is not running");
    }
    if (P1_GetState(0) != 1) {
        USLOSS_Console("Fail: state of sentinel should be ready");
    }
    int result = P1_Kill(P1_GetPID());
 
    if (result == -2) {
           USLOSS_Console("PASS\n");
    } 
     
    USLOSS_Console("P2_Finished\n");    
    return 0;
}