示例#1
0
文件: op2.c 项目: mitchbrain/os
int main()
{
    int fLines, start =2, i;
   char *fName = "worldcitiespoppartial.txt";
   float **fpArray;
    int childpid, fds[2];
    fpArray = fileInput(fName, &fLines);

    printf("Before it forks\n");
    pipe(fds);
    childpid = fork();

    if (childpid==0){
        printf("This is a child Process\n");
        fpArray = iSort(fpArray, (fLines/2), start);
        write(fds[1], fpArray, sizeof(long int)*3*fLines/2  );


    }
    else {
        printf("This is a parent Process\n");
        wait(NULL);
        read(fds[0], fpArray, sizeof(long int)*3*fLines/2);

        fpArray = iSort(fpArray, (fLines), (fLines/2));



    fpArray = mSort(fpArray, fLines);
    for(i=1;i<fLines; i++){
        printf("%.f %f %f\n", fpArray[i][0], fpArray[i][1], fpArray[i][2]);
    }


    }
   return(0);
}
示例#2
0
 void iSortBottomUp(E *A, intT n, intT m, F f) {
   iSort(A, (intT*) NULL, n, m, true, f);}
示例#3
0
 void iSort(E *A, intT n, intT m, Func f) {
   iSort(A, (intT*) NULL, n, m, false, f);}
示例#4
0
 void iSort(E *A, intT* bucketOffsets, intT n, intT m, F f) {
   iSort(A, bucketOffsets, n, m, false, f);}
示例#5
0
 void iSort(E *A, intT* bucketOffsets, intT n, intT m, bool bottomUp, F f) {
   long x = iSortSpace<E,intT>(n);
   char* s = (char*) malloc(x);
   iSort(A, bucketOffsets, n, m, bottomUp, s, f);
   free(s);
 }