tasks revision 9c3531d72aeaad6c5f01efe6a1c82023e1379e4d
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntCopyright (C) 1999, 2000 Internet Software Consortium.
3939cc42d8157258c3e65b99da2415e8adb532d3Tinderbox UserSee COPYRIGHT in the source root or http://www.isc.org/copyright for terms.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews$Id: tasks,v 1.4 2000/06/22 21:53:59 tale Exp $
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark AndrewsChanges I made last week to the task code simplified the task shutdown
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Huntand termination model. Here's how things now work:
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntWhen a task is shutdown:
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt Any "on shutdown" events for the task are posted
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt The "shutting down" attribute of the task is set
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt Any attempts to add shutdown events with isc_task_onshutdown()
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt will fail, since the task is already shutting down
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntTask shutdown can be initiated explicity, via a call to isc_task_shutdown(),
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupontor implicitly, when the following conditions occur:
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt The "shutting down" attribute of the task is not set
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt The task has no references
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt The task has an empty event queue
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
caf7c2fd25a7c4484e7044ecf622d352eabc8e19Mark AndrewsTask termination occurs when:
caf7c2fd25a7c4484e7044ecf622d352eabc8e19Mark Andrews
caf7c2fd25a7c4484e7044ecf622d352eabc8e19Mark Andrews The "shutting down" attribute of the task is set
caf7c2fd25a7c4484e7044ecf622d352eabc8e19Mark Andrews
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt The task has no references
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt The task has an empty event queue
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntNotes from the task/event discussion led by Bob Halley on 13 March 2000:
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntA task is an event queue.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt (task) --V
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt (event)-->(event)-->(event)
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt (runnable queue)--V
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt (task)-->(task)-->(task)
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntNormally only one task manager in an application.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntTask becomes runnable if it has a non-empty event queue.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntOne or more worker threads run tasks.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntEvent routines should be relatively short.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntOnly one runnable queue that all workers share.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntEvents for a task are always posted serially. Multiple worker threads
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Huntwill not be working on multiple events for one task at the same time.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Huntisc_event_send, posting an event, can't fail. It just adds an event
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Huntto the task queue.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntEvent action (callback) rules:
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt * no locks held on your behald when entering a callback.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt * not allowed to block, except when aquiring a lock.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt * not allowed to hold a lock when exiting the callback.
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntTIMERS?
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt
e32d354f754a5d7847a0862bcd6302827ea225bfEvan HuntOMAPI -- need taskmgr to omapi_lib_init
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt -- one task per client connection
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt