[Contents] [Index] [Help] [Retrace] [Browse <] [Browse >]

	AddMemHandler - Add a low memory handler to exec                 (V39)


	VOID AddMemHandler(struct Interrupt *);

	This function adds a low memory handler to the system.  The handler
	is described in the Interrupt structure.  Due to multitasking
	issues, the handler must be ready to run the moment this function
	call is made.  (The handler may be called before the call returns)

	Adding a handler from within a handler will cause undefined
	actions.  It is safe to add a handler to the list while within
	a handler but the newly added handler may or may not be called
	for the specific failure currently running.

	struct Interrupt *myInt;  /* Assume it is allocated */

	myInt->is_Node.ln_Pri=50;  /* Relatively early; before RAMLIB */

	/* Please fill in the name field! */
	myInt->is_Node.ln_Name="Example Handler";


	... /* and so on */

			; This is the handler code
			; We are passed a pointer to struct MemHandlerData
			; in a0, the value of is_Data in a1 and
			; ExecBase in a6.
			; We must not break forbid!!!
	; Start off assuming we did nothing
		moveq.l	#MEM_DID_NOTHING,d0
		move.l	memh_RequestFlags(a0),d1
		btst.l	#MEMB_CHIP,d1	; Did the failure happen in CHIP
		beq.s	handler_nop	; If not, we have nothing to do
		bsr	DoMyMagic	; Do the magic...
		; DoMyMagic frees whatever we can and returns d0 set...
		rts			; Return with d0 set...

	memHandler - A pointer to a completely filled in Interrupt structure
	             The priority field determine the position of the handler
	             with respect to other handlers in the system.  The higher
	             the priority, the earlier the handler is called.
	             Positive priorities will have the handler called before
	             any of the library expunge vectors are called.  Negative
	             priority handlers will be called after the library
	             expunge routines are called.
	             (Note:  RAMLIB is a handler at priority 0)

	RemMemHandler(), exec/interrupts.i

[Back to Amiga Developer Docs]