1. When execute command:
Surgemaster.c will first be executed.It will do follow works:
- Open file name.txt and calculate number of lines, store it in variable numnames.
- Open file off.txt and calculate its lines numoffs, and compare it with numnames.
- Create 4 pipelines:fifo1,fifo2,fifo3,fifo4
- Create loader1 process, which open fifo1, and write 1,2,...,numnames to fifo1.
- Create loader2 process, which open fifo2 and off.txt,copy every line's content in off.txt to fifo2 in sequence.
- Create loader3 process, which open fifo3, just keep writing increasing seq numbers to fifo3.
- Create loader4 process, which open fifo4 and cnt.txt,copy every line's content in cnt.txt to fifo4 in sequence.loadcnt keeps fifo4 filled with object counts.
- Create 2(clients) child processes, each process execute Surgeclient.
- Wait until all child processes finish.
Surgeclient.c will be executed.It do follow works:
1. Open objout.txt, read its content to array object[MATCHSIZE][OBJLIMIT].
2. Open name.txt, read its content to array seq[NAMESIZE].
3. Open mout.txt, read its content to array size[MATCHSIZE].
4. Open fifo1,fifo2,fifo3,fifo4.
5. Create client thread, each execute function ClientThread(i). ClientThread(i) defined in source file client11p.c.
ClientThread(i) do follow works:
1. According to MAXCONNS, this thread create n (n
2. Read fifo1 every time and store to count, then objindx = seq[count];
3. Read fifo4 and get value of numobjs.
4. Get the first connection with server.
reader[numconcts].conctno = connectsrvr();
|
5. Set up reader data structures
reader[0].objectno = objindx;
reader[0].nofiles = 1;
reader[0].startus = starttime.tv_usec;
reader[0].starts = starttime.tv_sec;
reader[0].fileno[0] = 0;
|
6. This ClientThread wait all reader thread finish.
ReaderThread do follow works:
1. write request to server.
Writerequest(filesread, readdat);
|
2. read data from server.
c = fillreadbuff(conctid,rbuff,sizeof(rbuff));
|
阅读(664) | 评论(0) | 转发(0) |