| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Named pipes: discussion on 64KB bou |
Recently I saw somebody asking questions on the 64KB boundary problem with named pipes on OS/2 2.x and 3.0. I wrote up this reply to him. I'm reposting it here in case anybody else might have been wondering about this same problem. ========== My personal opinion is that this is a mistake in the 32-bit OS/2 API that has persisted because named pipes code is still 16-bit and thunking has to be done. Somehow the 32-bit named pipes calls should have dealt with this issue so as to hide the problem from the programmer, but apparently this was not done as it was easier to document the problem as a restriction. Hopefully this problem won't persist on future versions of OS/2 based on the microkernel. Anyway, that said, there do appear to be several ways to deal with this problem. 1) You could allocate all buffers you plan to submit to named pipe DosWrite() and DosRead() calls via tiled memory allocation. As long as you don't allocate buffers larger than 64KB, then you won't have a problem any more. 2) You could put a wrapper around the DosWrite() and DosRead() calls that allocates a temporary tiled buffer if the buffer passed in crosses a 64KB boundary. You can tell if it crosses a 64KB boundary by comparing the pointer to the first byte of the buffer and the pointer to the last byte of the buffer to see if the top 16 bits differ. If they do differ, then you need to allocated a temporary tiled buffer and do the DosRead() and DosWrite() calls using that temporary buffer. For a DosWrite(), copy from the passed-in buffer into the temporary tiled buffer and then call DosWrite(). For DosRead(), read into the temporary tiled buffer and then copy the data into the passed-in buffer. 3) You could avoid using message mode named pipes and implement your own message boundary mechanism. I've done this and it works OK. Basically what you do is write wrapper functions (named something like write() and read() ) around DosWrite() and DosRead() that will fragment a write or read request up into as many requests as are needed such that requests are for less than 64KB of data and all buffer addresses passed to DosRead() and DosWrite() will not cross 64KB boundaries. Then write some code that uses these read() and write() functions to read/write a message header giving the length of the message and then read/write the message body based upon the length in the header. Make sure if your code is going to be reading/writing on the pipe using multiple threads that you use a mutex semaphore to make sure that the header and body read() and write() calls happen together without being interrupted by another thread trying to read/write on the pipe. An added benefit of this approach is that you can also effectively get rid of the 64KB message size limit as you can easily choose to use 32-bit message lengths in your message headers rather than the 16-bit length fields OS/2's message mode uses. --- Maximus/2 2.02* Origin: OS/2 Connection {at} Mira Mesa, CA (1:202/354) SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955 SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809 @PATH: 202/354 300 777 3615/50 396/1 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.