I'm stuck with resource managers

Hello,

I’m working with resource managers. All I have is 6.2.1 NC and online documentation. I can’t find anywhere in library reference online book a definition on _IO_SET_READ_NBYTES and _IO_SET_WRITE_NBYTES. I know what they are for, but I don’t know how they works. I can’t understand this sentence from programmers reference: “To tell it how many bytes were written we used the _IO_SET_WRITE_NBYTES() macro. It takes the nbytes that we give it and stores it in the context structure (ctp). Then when we return to the library, the library takes this nbytes and passes it as the second parameter to the MsgReplyv(). The second parameter tells the kernel what the MsgSend() should return. And since the write() function is calling MsgSend(), that’s where it finds out how many bytes were written.” What does it mean we return to resource manager library??? And how library can take nbytes, which was set with macros above? Can I have some easy explanation here? Thank you in advance.

Darius

You your call back are doing a return. It returns to the function that called your callback, that function is part of the resource manager library/framework. The detail are all hidden obviously.

You can download the source of the resource manager framework at cvs.qnx.com (it’s the 6.1 version I beleive) to learn about inner working of the resource manager framework/library.

Hello,

Hm? As I know my callback is for example io_read and this callback is called when resource manager receives IO_READ message, so as I think io_read is called by dispatch_block. Or am I wrong? So dispatch_block is the function that returns nbytes to the sender. Isn’t it?
Thank you for replying.

Best regards,
Darius

No quite, it’s actualy dispatch_handler, in turn this function will call MsgReply( ) after having called your callback. MsgReply is most probably buried deep inside dispatch_handler

something like this (simplified):

   switch (ctp->msg.type) {
      ....
      case _IO_WRITE:
            ret = your_io_write_callback(ctp ...);
            if (ret == RESMGR_NOREPLY)
                break;

            if (ret <= 0) {
                MsgReplyv(ctp->rcvid, ctp->result, ctp->iov, -ret);
            } else {
                MsgError(ctp->rcvid, ret);
            }
            break;
    }