Jalada home about archive

Asynchronous Notification and ATC in Ada

9th February 2010

These are lecture notes from my Computer Science course, not a general reference for "Asynchronous Notification and ATC in Ada"

What’s an Asynchronous Notification technique? It’s a way of getting the attention of something (a task/process/thread/gerbil) without the task/process/thread/gerbil waiting. Basically an interrupt.

Who needs it?

Alternative: Polling

Guess what? Polling is slow and bad.

Ada

ATC is implemented by using the select statement. Here’s an example:

select
	X.entry_call; -- This can have some delay too if you want.
	-- sequence of statements
then abort
	-- while we're waiting for this to occur, execute this:
	-- sequence of statements
end select;

If the entry call can occur immediately it does, and you never do the stuff after abort. If it can’t, then you execute the other stuff. However if the entry call then can be executed, execution is aborted. If you get all of the abort done, you stop ‘listening’ out for an entry call.

You an’t have an accept statement in the then abort bit.

The slides give some examples as to what will happen in different circumstances, but it’s fairly intuitive.

Generally you’d use this technique for something like receiving an error. e.g. you wouldn’t use it for ordinary operation; probably due to the fact that it causes this ‘aborting’ which sounds nasty to me.

Comments

blog comments powered by Disqus