home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / ada / 2181 < prev    next >
Encoding:
Internet Message Format  |  1992-07-23  |  2.4 KB

  1. Path: sparky!uunet!haven.umd.edu!mimsy!alex
  2. From: alex@cs.umd.edu (Alex Blakemore)
  3. Newsgroups: comp.lang.ada
  4. Subject: Re: Ada tasking rules and AST's...
  5. Message-ID: <59190@mimsy.umd.edu>
  6. Date: 23 Jul 92 15:27:56 GMT
  7. References: <1992Jul22.194130.10544@europa.asd.contel.com>
  8. Sender: news@mimsy.umd.edu
  9. Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
  10. Lines: 48
  11.  
  12. In article <1992Jul22.194130.10544@europa.asd.contel.com> king@ssvax.gte.com (Larry King) writes:
  13. > My question is how can I get Ada to do a rescheduling of the
  14. > tasks to get this new entry to run.  There is one process that takes
  15. > some amount of time but if the system call has finished we would like
  16. > the AST entry to run before this task normally finishes.  Currently we 
  17. > issue a delay statement for the time
  18. > DURATION'SMALL but this causes us to lose 10 milliseconds of time just
  19. > to do the delay.  It does cause VAX Ada to run the AST entry but we would like
  20. > to avoid losing the 10 milliseconds if possible.  Does VAX Ada (or any
  21. > Ada for that matter) allow you to force an execution of the next entry on 
  22. > the queue before the current task has completely finished?  
  23.  
  24. I'm not sure I understand your question completely, but you can use
  25.  
  26.   delay 0.0; -- the delay does not have to be positive
  27.              -- can even be negative (in which case your system 
  28.              -- moves backwards in time, actually same as zero)
  29.  
  30. This inserts a synchronization point in your code - when it executes
  31. the run time system must relinquish the processor to any higher
  32. priority eligible task.  If there is no such task, then this is a noop
  33. except for the time to check the ready queue.  You can also insert 
  34. selective accept statements with else parts to check specific queues.
  35.  
  36. Both these methods involve stating explictly at which points you are willing
  37. to relinquish the processor or accept a new entry.
  38.  
  39.   ... code, possibly in another accept stmt
  40.   select
  41.     accept my_ast_entry do
  42.       ... do something; 
  43.  
  44.     end;
  45.   else
  46.      null;  -- no ast was there
  47.   end select;
  48.   ... get back to previous work
  49.  
  50. scattering this throughout could get a little ugly - there are probably
  51. better ways.  Using 'Count is NOT one of them in general.
  52. Ada9X offers some other nice alternatives to allow asynchronous
  53. transfer of control and handle interrupts.
  54.  
  55. hope this helps
  56.                     
  57. -- 
  58. -------------------------------
  59. Alex Blakemore alex@cs.umd.edu
  60.