rcook@eagle.wesleyan.edu (11/20/90)
Suppose I am making two asynchronous AppleTalk (or Device Manager, for that matter) like this: var MyParmBlock: ParmBlkPtr; async: boolean; begin ... async := true; { make the calls asynchronously } MyParmBlk := ParmBlkPtr(NewPtr(sizeof(ParmBlkPtr))); with MyParmBlock^ do begin { fill in data } end; err := SomeAppleTalkCall(MyParmBlock,async); with MyParmBlock^ do begin { fill in some more data } end; err := SomeOtherAppleTalkCall(MyParmBlock,async); ... end; Assuming the first AppleTalk call has not yet been completed by the time the second call is made, is it safe to reuse MyParmBlock in this way? Ignore for now the fact that I can't go back and check if the first call was completed successfully. In other words, when something is placed in an I/O queue, is a copy of the parameter block made or is a pointer to your data placed in the queue instead? I assume it makes a copy, but I want to hear this from someone who knows for sure. Thanks. Randall Cook rcook@eagle.wesleyan.edu
ech@cbnewsk.att.com (ned.horvath) (11/20/90)
From article <1990Nov19.130139.35978@eagle.wesleyan.edu>, by rcook@eagle.wesleyan.edu: - Suppose I am making two asynchronous AppleTalk (or Device Manager, for that - matter) like this: - - var - MyParmBlock: ParmBlkPtr; - async: boolean; - - begin - ... - async := true; { make the calls asynchronously } - MyParmBlk := ParmBlkPtr(NewPtr(sizeof(ParmBlkPtr))); - - with MyParmBlock^ do - begin - { fill in data } - end; - err := SomeAppleTalkCall(MyParmBlock,async); - - with MyParmBlock^ do - begin - { fill in some more data } - end; - err := SomeOtherAppleTalkCall(MyParmBlock,async); - ... - end; - - Assuming the first AppleTalk call has not yet been completed by the time the - second call is made, is it safe to reuse MyParmBlock in this way? Ignore for - now the fact that I can't go back and check if the first call was completed - successfully. In other words, when something is placed in an I/O queue, is a - copy of the parameter block made or is a pointer to your data placed in the - queue instead? I assume it makes a copy, but I want to hear this from someone - who knows for sure. Thanks. Your intuition is wrong: your parameter block -- not a copy -- is linked into the I/O queue, and becomes the property of the OS until the request completes. A common technique is to set ioResult to 1 before the call (some drivers do this for you) since all valid completions are <= 0. You can then poll the ioResult field from your event loop if you don't feel up to doing an ioCompletion routine. Notice that the call "completes" -- i.e. never really gets started -- if the call returns anything but noErr (0). ALWAYS check the err return! =Ned Horvath=
dorner@pequod.cso.uiuc.edu (Steve Dorner) (11/20/90)
>In other words, when something is placed in an I/O queue, is a >copy of the parameter block made or is a pointer to your data placed in the >queue instead? I assume it makes a copy I would bet that it does NOT. Why should it? It has your parameter block, into which it intends to store a result code. Why make an extra copy? Where would the copy be stored? How many such "backup blocks" would be allocated? Would they go on the heap? If so, then you'd never be able to make device manager calls at interrupt level. >but I want to hear this from someone >who knows for sure. Thanks. I don't know for sure; sorry. -- Steve Dorner, U of Illinois Computing Services Office Internet: s-dorner@uiuc.edu UUCP: uunet!uiucuxc!uiuc.edu!s-dorner
resnick@cogsci.uiuc.edu (Pete Resnick) (11/20/90)
rcook@eagle.wesleyan.edu writes: >Assuming the first AppleTalk call has not yet been completed by the time the >second call is made, is it safe to reuse MyParmBlock in this way? Ignore for >now the fact that I can't go back and check if the first call was completed >successfully. In other words, when something is placed in an I/O queue, is a >copy of the parameter block made or is a pointer to your data placed in the >queue instead? I assume it makes a copy, but I want to hear this from someone >who knows for sure. Thanks. First, the Device Manager does not make copies, it uses your parameter block. And I *know* that if you do this making the Device Manager calls in MacTCP, MacTCP will yell and scream about it being a duplicate block. I don't know if Appletalk depends on or even will check if you are using the same block for two operations simultaneously, but either way it cannot be safe. pr -- Pete Resnick (...so what is a mojo, and why would one be rising?) Graduate assistant - Philosophy Department, Gregory Hall, UIUC System manager - Cognitive Science Group, Beckman Institute, UIUC Internet/ARPAnet/EDUnet : resnick@cogsci.uiuc.edu BITNET (if no other way) : FREE0285@UIUCVMD