[comp.sys.amiga.tech] How to close a device, cont

rosenbergr@abo.fi (Robin Rosenberg) (12/22/88)

In article <587@abo.fi>, vinsci@abo.fi (Leonard Norrgard) writes:
> 
>   What is the *correct* order to close a device and free buffer memory &
> replyports?
> ...

One more question concerning the same subject:

When I do CloseDevice. What happens to a (maybe) pending I/O-request. Do
I have to AbortIO(it) or does CloseDevice do that. If I have to abort it,
what happens if the request is not pending anymore ?. I can't find any way
to be sure that a request is not pending. Ok I do CheckIO and find it's
still pending, then I do AbortIO. But if the request is returned between
CheckIO and AbortIO, i will be aborting a nonpending request. Does anyone
know the *CORRECT* way of closing up a device ?

	thnx
---
Robin Rosenberg, Finn|, 22340 Geta, Finland
	     or: Studentbyn 40A3, 20510 ]bo, Finland
Note: | is o with two dots on top         
      ] is A with a ring on top.
"The use of COBOL cripples the mind; it's teaching should therefore be regarded
as a criminal offense" 

jesup@cbmvax.UUCP (Randell Jesup) (12/28/88)

In article <588@abo.fi> rosenbergr@abo.fi (Robin Rosenberg) writes:
>In article <587@abo.fi>, vinsci@abo.fi (Leonard Norrgard) writes:
>>   What is the *correct* order to close a device and free buffer memory &
>> replyports?

	Close it, then free things.

>When I do CloseDevice. What happens to a (maybe) pending I/O-request. Do
>I have to AbortIO(it) or does CloseDevice do that. If I have to abort it,
>what happens if the request is not pending anymore ?. I can't find any way
>to be sure that a request is not pending. Ok I do CheckIO and find it's
>still pending, then I do AbortIO. But if the request is returned between
>CheckIO and AbortIO, i will be aborting a nonpending request. Does anyone
>know the *CORRECT* way of closing up a device ?

	Almost correct.  You always want to WaitIO(it) after an AbortIO.
AbortIO asks for an abort, but the abort may take time to complete, or
it maybe too late to abort.  The WaitIO() assures that the request has been
replied, and it's safe to reuse it.

	Another note for those using IORequests, that has been discussed
here before:  DO NOT assume that a signal on the reply port for something that
has been SendIO()ed or BeginIO()ed means the message has come back.  Use
the signal as an instruction to either WaitIO() or CheckIO then WaitIO if
it is done. (You can also use CheckIO/GetMsg if you are using no other
IORequests on that port, but I recommend against it).

	Welcome to the wonderful world of IO!  :-)

-- 
Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup