Professional Web Applications Themes

pipe implementation on solaris - UNIX Programming

Hello, Is there semantics difference between the pipes are implemented on solaris and on Linux. I have a program which runs fine on Linux however some times on solaris I get some unpredictable results. I have assumed the pipe to be read blocking on both linux and solaris is that ok? Thanks, Amit Khandelwal...

  1. #1

    Default pipe implementation on solaris

    Hello,
    Is there semantics difference between the pipes are implemented on
    solaris and on Linux. I have a program which runs fine on Linux
    however some times on solaris I get some unpredictable results. I have
    assumed the pipe to be read blocking on both linux and solaris is that
    ok?

    Thanks,
    Amit Khandelwal
    Amit Guest

  2. #2

    Default Re: pipe implementation on solaris

    On Sat, 14 Feb 2004 06:24:59 -0800, Amit wrote:
     

    You'll have to be more specific than "unpredictable results".

    Unless you've explicitly put the file descriptors into non-blocking mode
    then, yes, a read from a pipe will block until there is data available.
    However, note that pipes behave like network sockets, not files. Let's
    consider the following timeline where process A is writing data into the
    pipe and process B is reading the data:

    process A process B
    ---------------- ---------------
    write(wfd,buf,4)
    read(rfd,buf,8)
    write(wfd,buf,4)

    The read() from process B will read the four bytes in the pipe and have a
    return value of four. It will not block until eight bytes are available. On
    a monoprocessor system it will frequently be the case that both write()'s
    by process A will complete before process B is allowed to run. So process
    B's read() will normally return all eight bytes. But there is no guarantee
    that will happen. It's possible for a context switch to occur between the
    two write()'s by process A. And on a multiprocessor system it is even more
    likely that only part of the data will be in the pipe when process B issues
    it's read() since the two processes can be running simultaneously on
    different CPUs.

    Also, don't forget that pipes can buffer only a finite amount of data. If
    process A attempts to write more data than the pipe can buffer than part of
    the contents of buf[] will put into the pipe and process A will be put to
    sleep until process B reads that data. Process A will then be woken up and
    allowed to copy more data from its buf[] into the pipe.
    Kurtis Guest

  3. #3

    Default Re: pipe implementation on solaris

    com (Amit) writes:
     


    That is OK but what is "unpredicatble? Are you perhaps:

    expecting message boundaries to be preserved? (they are not)

    that pipes are unidirectional (Solaris pipes are not)?

    expecting to be able to move large amounts of data
    atomically (you can't).

    I can't think of any other wrong assumtions.

    Casper
    Casper Guest

Similar Threads

  1. Replies: 5
    Last Post: December 30th, 11:30 PM
  2. solaris 10 zone / container question (or Solaris 9)
    By anna in forum Linux / Unix Administration
    Replies: 6
    Last Post: June 23rd, 04:24 PM
  3. Replies: 3
    Last Post: August 13th, 03:43 PM
  4. Replies: 2
    Last Post: July 2nd, 02:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139