Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
82 user(s) are online (46 user(s) are browsing Forums)

Members: 0
Guests: 82

more...

Headlines

 
  Register To Post  

Is it possible to detect if a function is called from within an interrupt?
Home away from home
Home away from home


See User information
The thread subject says it all. If there is a function that may get called both by user-code, and also from within an interrupt, is there any way to detect whether it's been called from the interrupt or not?

Hans

http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
Go to top
Re: Is it possible to detect if a function is called from within an interrupt?
Not too shy to talk
Not too shy to talk


See User information
@Hans

I don't know, but if you need a function to do something that doesn't have to be synchronous, you could have a server process and make the function signal it to do the task in question...

Go to top
Re: Is it possible to detect if a function is called from within an interrupt?
Home away from home
Home away from home


See User information
@xeron

Quote:

xeron wrote:
@Hans

I don't know, but if you need a function to do something that doesn't have to be synchronous, you could have a server process and make the function signal it to do the task in question...


What you're describing is just basic interrupt handling.

I have some code that might be called by a reset handler, and it's not practical to create a separate version for that purpose. Multitasking/interrupts are disabled during the reset handler. A simple method of detecting when this is the case from within the function would be helpful; otherwise I could always create a global flag that could be flicked on and off (yuck) to indicate what mode it's in.

Come to think of it, I assumed that a reset handler is called from within an interrupt, but this may or may not be true.

Hans

http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
Go to top
Re: Is it possible to detect if a function is called from within an interrupt?
Not too shy to talk
Not too shy to talk


See User information
@Hans

I'm guessing you want to be able to determine if interrupts and/or multitasking are disabled, then?

Go to top
Re: Is it possible to detect if a function is called from within an interrupt?
Home away from home
Home away from home


See User information
@xeron

Quote:

xeron wrote:
@Hans

I'm guessing you want to be able to determine if interrupts and/or multitasking are disabled, then?

Yes.

Hans

http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
Go to top
Re: Is it possible to detect if a function is called from within an interrupt?
Quite a regular
Quite a regular


See User information
@Hans

No, there isn't. You'd have to set a global flag in your interrupt function.

cheers
tony
Go to top
Re: Is it possible to detect if a function is called from within an interrupt?
Home away from home
Home away from home


See User information
@tonyw

Quote:

tonyw wrote:
@Hans

No, there isn't. You'd have to set a global flag in your interrupt function.


Ah well, global flag it is then.

Hans

http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
Go to top
Re: Is it possible to detect if a function is called from within an interrupt?
Just popping in
Just popping in


See User information
@Hans

It's been long enough since I've seen Amiga nterrupt code t forget things exactly, I've been doing some ARM stuff at work to have some thoughts that may or may not work. You mentioned that interrupts are disabled in the reset handler.

In an interrupt handler, I'd think you'd be looking somewhere to see which of a possible set of events triggered an interrupt, to determine exactly what the handler needs to do each time in. For ARM, we use the AIC peripheral to enable/disable interrupts for each other peripheral block (usart, spi, usb controller, etc). Could you check that the Radeon interrupt in Amiga's interrupt controller is enabled or disabled, and if disabled then assume the reset brought us here, if enabled then interrupt brought us here? That'd use the interrupt controller itself as your global flag, though you'd want some assurance that an interrupt event would always look on and a reset event would always look off for that.

This would check the whole system interrupt controller status for Radeon interrupt enable, not checking inside the Radeon's own interrupt status values for which particular Radeon event triggered a Radeon interrupt.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project