home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!munnari.oz.au!penguin!gduncan
- From: gduncan@philips.oz.au (Gary Duncan)
- Message-ID: <1993Jan7.092127.13752@philips.oz.au>
- Date: Thu, 7 Jan 93 09:21:27 GMT
- Organization: Philips Public Telecommunications Systems, Melbourne, Australia
- Subject: Flushing Devices; C= doco (mutter!)
- Lines: 66
-
- Ever done an "RTFM" on a key issue, can't find the answer, asked for
- help then later find it was in "TFM" but so described as to be easily
- overlooked but allow the manual writers to say "well its in there" ?
-
- Yes ? Causes some stress doesn't it ? Definitely generates negative
- thoughts. Anyway...
-
- A few days ago I posed a question on how to flush unused
- devices out of RAM from a program (as distinct from doing it from the
- command line using "Avail Flush", for example). Nothing in the
- RKMs seemed to answer this question (but read on).
-
- In my case getting rid of the serial device was the issue. Having it hang
- around unused after my program exitted gave a false impression of a
- memory leak.
-
- Well I got some helpful replies on how to force a flush from
- requesting gigabytes (thus causing Exec to flush unused libraries
- and devices from RAM) to suggestions of using the Flush entry in
- a device. Fortunately someone had made a passing reference to some
- code examples so I managed to trip over one of C='s 1.3 examples
- (dated May 1990) issued on Fish Disks and saw a neat example on
- how to do it (para-coded below).
-
- Armed with this info I rescanned the RKM-Libraries (ed 3) index
- and noticed a "FlushDevices()" entry {my brain had been previously
- programmed to look for keywords like Remove/Delete/Expunge and in
- big bold letters, not as a side issue to a specific chapter}.
- This lead to a discussion/code as shown below and in fact answered my query.
-
- So what I'm saying is that there is a real deficiency in that
- manual to do with this issue. There should at least have been
- a reference to RemDevice() which would have lead on one.
-
- I feel better now :)
-
- Passing thought ; why the heck aren't unused libraries/devices
- flushed automatically anyway? Sounds like a legacy of the days
- when hard disks were rare and dragging a device off floppy was
- time-consuming. Those days are gone...
-
-
- - Gary
-
-
- --------------------------------------------------------------
- extern struct ExecBase *SysBase;
-
- void
- FlushSerDevice (void)
-
- {
- DEVICE *dev;
-
- Forbid ();
- if (dev = (DEVICE *) FindName (&SysBase->DeviceList, SERIALNAME))
- RemDevice (dev);
-
- Permit ();
- }
-
- --
- -----------------------------------------------------------------
- Gary Duncan gduncan@rosella.pts.philips.oz.au
- Philips Public Telecommunications Systems Phone: +61 3 8813666
- Melbourne, Australia Fax: +61 3 8813577
-