[comp.sys.amiga.programmer] Help with forbid

dbucciar@isis.cs.du.edu (Dom Bucciarelli) (01/28/91)

I'm trying to use the forbid() call to stop multitasking while I do a 
benchmark code segment.  Unfortunately, I don't know how to tell my 
Lattice C compiler/linker where to find the routine.  I assume it's in 
"exec.lib" but don't know how to get at it.

Also, what is the "un-forbid()" call to re-enable multitasking?  Or can I 
let the program exit, expecting everything to go back to normal?

This seems like a pretty basic question, but I'm new to Amiga programming,
so please be gentle.

Thanks in advance,
Dom

dbucciar@isis.UUCP or dbucciar@isis.cs.du.edu
-- 
---------------------------------------------------------------------------
|o|                         Dom Bucciarelli                             |o|
|o|                     (dbucciar@nyx.cs.du.edu)                        |o|
---------------------------------------------------------------------------

lkoop@pnet01.cts.com (Lamonte Koop) (01/28/91)

dbucciar@isis.cs.du.edu (Dom Bucciarelli) writes:
>I'm trying to use the forbid() call to stop multitasking while I do a 
>benchmark code segment.  Unfortunately, I don't know how to tell my 
>Lattice C compiler/linker where to find the routine.  I assume it's in 
>"exec.lib" but don't know how to get at it.

If you are doing direct library calls (avoiding linking with amiga.lib), the
include file to use is proto/exec.h. [and the associated pragma include file
if they are seperate on your system].  Otherwise, if you are linking with
amiga.lib, blink will simply find it there.  The prototype for Forbid() is
simply: void Forbid(void)

>Also, what is the "un-forbid()" call to re-enable multitasking?  Or can I 
>let the program exit, expecting everything to go back to normal?

The call to use is known as Permit().  DO NOT simply exit the program with a
Forbid() in place [This is a "hanging Forbid()"].  Under 1.2, you'll get
system hangs, and 1.3 is not very fond of it either on occasion.  You should
have one Permit() call for every Forbid() (They can be nested).

>-----------------------------------------------------------------------------
>
>|o|                         Dom Bucciarelli                             |o|
>|o|                     (dbucciar@nyx.cs.du.edu)                        |o|
>---------------------------------------------------------------------------


                             LaMonte Koop
 Internet: lkoop@pnet01.cts.com         ARPA: crash!pnet01!lkoop@nosc.mil
           UUCP: {hplabs!hp-sdd ucsd nosc}!crash!pnet01!lkoop
  A scientist is one who finds interest in the kinetic energy of Jell-O
   moving at ridiculous velocities...an engineer is one who can find a
               real-life application for such silliness.

bombadil@diku.dk (Kristian Nielsen) (01/29/91)

dbucciar@isis.cs.du.edu (Dom Bucciarelli) writes:

>I'm trying to use the forbid() call to stop multitasking while I do a 
>benchmark code segment.  Unfortunately, I don't know how to tell my 

Are you sure you wouldn't want to use Disable()/Enable() instead, to turn
off interrupts as well? This is even more cruel to the multitasking
environment than forbid()/permit(), but otherwise the CPU still spends time
in the interrupt handlers. Just use something like this:

.
.
void main(void){
  Disable();
  /* Do benchmark... */
  Enable();
}


	Kristian

==========================================================================
Kristian Nielsen                          |      ///   Only the AMIGA
Student at DIKU, University of Copenhagen |     ///
(Department of Computer Science)          | \\\///     makes it possible!
Denmark                                   |  \XX/
==========================================================================