示例#1
0
int
Child(char *arg)
{
    int    pid;
    char   str[64]= "This is the first page";

    GetPID(&pid);
    Tconsole("\nChild(%d): starting\n", pid);

    Tconsole("Child(%d): str = %s\n", pid, str);
    Tconsole("Child(%d): strlen(str) = %d\n", pid, strlen(str));

    memcpy(vmRegion, str, strlen(str)+1);  // +1 to copy nul character

    Tconsole("Child(%d): after memcpy\n", pid);

    if (strcmp(vmRegion, str) == 0)
        Tconsole("Child(%d): strcmp first attempt worked!\n", pid);
    else
        Tconsole("Child(%d): Wrong string read, first attempt\n", pid);

    assert(vmStats.faults == 1);
    assert(vmStats.new == 1);

    SemV(sem);  // forces a context switch with start5

    if (strcmp(vmRegion, str) == 0)
        Tconsole("Child(%d): strcmp second attempt worked!\n", pid);
    else
        Tconsole("Child(%d): Wrong string read, second attempt\n", pid);

    Tconsole("Child(%d): checking various vmStats\n", pid);
    assert(vmStats.faults == 1);
    assert(vmStats.new == 1);
    assert(vmStats.pageOuts == 0);
    assert(vmStats.pageIns == 0);

    Tconsole("Child(%d): terminating\n\n", pid);

    Terminate(117);
    return 0;
} /* Child */
示例#2
0
int
Child(char *arg)
{
    int   pid;
    char  *zeros;

    GetPID(&pid);
    Tconsole("Child(): starting (pid = %d)\n", pid);

    zeros = calloc(USLOSS_MmuPageSize(), 1);
    if (memcmp(vmRegion, zeros, USLOSS_MmuPageSize()) != 0) {
        Tconsole("Child(): VmRegion is not zero-filled\n");
        abort();
    }
    verify(vmStats.faults == 1);

    SemV(sem);

    Terminate(117);
    return 0;
} /* Child */
示例#3
0
int
start5(char *arg)
{
    int  pid;
    int  status;

    Tconsole("start5(): Running %s\n", TEST);
    Tconsole("start5(): Pagers: %d, Mappings : %d, Pages: %d, Frames: %d, Children %d, Iterations %d, Priority %d.\n", PAGERS, MAPPINGS, PAGES, FRAMES, CHILDREN, ITERATIONS, PRIORITY);

    vmRegion = VmInit( MAPPINGS, PAGES, FRAMES, PAGERS );

    Spawn("Child", Child,  0,USLOSS_MIN_STACK*7,PRIORITY, &pid);
    SemP( sem);
    Wait(&pid, &status);
    verify(status == 117);

    Tconsole("start5 done\n");
    //PrintStats();
    VmDestroy();
    Terminate(1);

    return 0;
} /* start5 */
示例#4
0
int
start5(char *arg)
{
    int  pid;
    int  status;

    Tconsole("start5(): Running:    %s\n", TEST);
    Tconsole("start5(): Pagers:     %d\n", PAGERS);
    Tconsole("          Mappings:   %d\n", MAPPINGS);
    Tconsole("          Pages:      %d\n", PAGES);
    Tconsole("          Frames:     %d\n", FRAMES);
    Tconsole("          Children:   %d\n", CHILDREN);
    Tconsole("          Iterations: %d\n", ITERATIONS);
    Tconsole("          Priority:   %d\n", PRIORITY);

    status = VmInit( MAPPINGS, PAGES, FRAMES, PAGERS, &vmRegion );
    Tconsole("start5(): after call to VmInit, status = %d\n\n", status);
    assert(status == 0);
    assert(vmRegion != NULL);

    SemCreate(0, &sem);

    Spawn("Child", Child, NULL, USLOSS_MIN_STACK * 7, PRIORITY, &pid);

    SemP( sem);

    Wait(&pid, &status);
    assert(status == 117);

    Tconsole("start5(): done\n");
    //PrintStats();
    VmDestroy();
    Terminate(1);

    return 0;
} /* start5 */