Dependent Origination

stream multiplexing

Posted on: September 27, 2008

04/05/2007

最近可圈可点的bug比较多哈 问 题的起因是不想让apache一次load太大的executable, 所以有些东西就要fork another process, 然后用inter-process communication来feed input and obtain output. 但是问题是output很多时候是stdout和stderr都有结果. 所以parent process在读的时候有可能死锁. 比方说先读stderr, 再读stdout的话. 有一种情况是stdout写满了所以child process就sleep and wait on stdout. 但是parent process在sleep and wait on stderr. 反之, 先读stdout, 后读stderr, 也会有类似的race condition.

老板说你想改的话, 应该用select去读多个steam. 以前只在socket programming里面用过, 没想到也可以用在file descriptor上面. 花了大半天的时间, 改了之后还挺得意的. 而且据说任何一本unix textbook上面都会告诉你, 这个是standard solution 不过用select也有很多trap, 很容易造成deadlock. linux上面的man pages还是很管用的

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

September 2008
M T W T F S S
« Dec   Oct »
1234567
891011121314
15161718192021
22232425262728
2930  

Twitter

  • is reflecting on the past three years and reading the article on divided self aptly showing up at the top of my tweeter feed. 3 months ago
  • is having a nice feeling of connecting dots all over the place. they are now illuminating the same point. 5 months ago
  • Style Transfer is fun! TensorFlow rocks! #WTM17 https://t.co/zYP0IFIDfp 6 months ago
  • couldn't get over the jetlag, sleeping during the day from seven to four, for days. 8 months ago
  • is emptying trash and happily discovering the available disk space now ranks at 100G+. 9 months ago

Flickr Photos

%d bloggers like this: