[saga-rg] Re: Meeting Notes: Messaging API

John Shalf JShalf at lbl.gov
Tue Nov 22 23:40:44 CST 2005




On Nov 22, 2005, at 4:52 PM, Andrei Hutanu wrote:
> John Shalf wrote:
>> On Nov 22, 2005, at 3:21 PM, Andre Merzky wrote:
>>
>>> Quoting [Andrei Hutanu] (Nov 22 2005):
>>>
>>>> Andre,
>>>>
>>>> Thanks for the notes!
>>>>
>>>>>
>>>>> - read: two step mechanism:
>>>>>   (int   handle, int size) = query_size ();
>>>>>   (char* buffer)           = read (handle, size);
>>>>>
>>>>>   - handle can be zero, if size is known (one step read)
>>>>>   - buffer needs to be allocated by application.
>>>>>   - if size is zero, the buffer is allocated by the
>>>>>     implementation and returned to be freed by the
>>>>>     application (one step read)
>>>>>
>>>>>
>>>> This part is a bit confusing .. with the one step read you lose the
>>>> length of the message?
>>>> it should probably be  (char* buffer, int size) = read () for  
>>>> the one
>>>> step read ..Or am I reading it wrong..
>>>
>>>
>>> No, you are probably right.  IIRC, we pinned down two
>>> different semantics for one step read:
>>>
>>>  a) size is known, malloc by application
>>>     (buffer) = read (handle = NULL, size);
>>
>>
>> The read should be like POSIX and return the buffer size rather  
>> than  the buffer itself.
>>
>>>  b) size unknown, malloc by implementation
>>>     (buffer, size) = read ();
>>
>>
>> Wait, I think Andre had it correct.  There is also a
>>     c) size unknown, but buffer is presized to what the  
>> application  programmer expects to the the max message size.   
>> Under this  circumstance, you can do a single step read which  
>> returns the  *actual* size of the read.  If the message was larger  
>> than the buffer  size declared in the read(), then the read will  
>> be truncated and the  truncated message data will be dropped.
>>     int read(handle, buffer, size)
>>     buffer is presumed to be "size" bytes in length.  Read returns  
>> the  actual message size.  If message is larger than buffer size,  
>> then  truncated data is dropped.
>
> Isn't this the same as a? I see only two cases :
> a) user knows something (max expected size or actual size) - int  
> read(buffer, size) described above
> b) user doesn't know anything - (buffer, size) = read ();
> I'm probably missing something obvious ..

Whoops,
then we really need
	a) size is not known, so we do two step
	int getMessageSize(handle);
	<malloc by application>
	int read(handle,buffer,size)

	b) size is not known, but we let implementation malloc automatically
	char *readAutoAllocate(handle);

	c) size is known, so we just do a one-step read
	int read(handle,buffer,size);
	





More information about the saga-rg mailing list