[fpc-pascal] Inter-process communication, a cautionary tale

OBones obones at free.fr
Thu Jul 19 09:17:46 CEST 2012


Mark Morgan Lloyd wrote:
> OBones wrote:
>> Mark Morgan Lloyd wrote:
>>> Basically, what I was trying to do was this. In the main thread:
>>>
>>>     fIpcPipe:= CreateNamedPipe(PChar(fIpcName), PIPE_ACCESS_INBOUND,
>>>                         PIPE_TYPE_MESSAGE + PIPE_READMODE_MESSAGE,
>>>                                 1, 0, 0, 1000, NIL (* @sa *) );
>>>
>>> That works. Fire up a background reader thread, and make sure that 
>>> the main thread doesn't proceed...
>> So you are not creating the "read" pipe in the context of the thread 
>> that actually reads from it?
>> I'm not sure that this is actually supported, maybe you should try to 
>> create it in the context of the reading thread.
>
> I agree, but ever since threads were introduced (OS/2 v1 or perhaps 
> even earlier) doctrine has had it that ownership (of memory, handles 
> and so on) was by process while state (stack content and runability) 
> was by thread.
Yes, I agree, that's the basic principle with threads. But that's Win32 
we are talking about here, and more often than not, things only work 
withing the context of the same thread, especially when it comes to 
resource handles.



More information about the fpc-pascal mailing list