Chinaunix首页 | 论坛 | 博客
  • 博客访问: 429272
  • 博文数量: 123
  • 博客积分: 2686
  • 博客等级: 少校
  • 技术积分: 1349
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-23 22:11
文章分类
文章存档

2012年(3)

2011年(10)

2010年(100)

2009年(10)

我的朋友

分类: LINUX

2010-08-05 14:21:21

1. When execute command:
 

./Surge 2 3 4

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));



阅读(627) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~