home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / amiga / programm / 19019 < prev    next >
Encoding:
Text File  |  1993-01-21  |  2.4 KB  |  64 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!gatech!concert!samba!usenet
  3. From: Todd_Lewis@unc.edu (Todd M. Lewis)
  4. Subject: Re: spawning a task with a Delay() in it
  5. Message-ID: <1993Jan21.160755.23617@samba.oit.unc.edu>
  6. Sender: usenet@samba.oit.unc.edu
  7. Nntp-Posting-Host: guitar.oit.unc.edu
  8. Organization: UNC Office of Information Technology
  9. References: <1993Jan20.193205@informatik.uni-kl.de>
  10. Date: Thu, 21 Jan 1993 16:07:55 GMT
  11. Lines: 51
  12.  
  13. [Oh brother, not again...]
  14.  
  15. In article <1993Jan20.193205@informatik.uni-kl.de> c_feck@informatik.uni-kl.de  
  16. (Christop Feck) writes:
  17. >mks@cbmvax.commodore.com (Michael Sinz) writes:
  18. >>Remember to open any libraries from the process that will call them.
  19. >
  20. >Is it really not allowed to pass e.g. IntuitionBase to another process? Why?
  21. >If I start a new process which should have (considering SAS C) the __saveds
  22. >keyword in the process entry to allow access to global variables, how could I
  23. >leave #?Base out and open them for this process only?
  24.  
  25. Have each task/process open the libraries it needs.  The example
  26. below lets each task open libraries so that they can share base
  27. pointers.  For most libraries around today OpenLibrary() returns
  28. the same base pointer for each opener.  The code below assumes
  29. that is the case, but will at least allow your program to 
  30. exit gracefully should that change in the future.
  31.  
  32. BOOL taskOpenLibrary(char *name, LONG version, void **base)
  33.  {
  34.   void *tmp;
  35.   tmp = OpenLibrary( name, version );
  36.   if ( tmp )
  37.     {
  38.       if ( !*base ) *base = tmp;
  39.       if (  *base != tmp )
  40.         {
  41.           CloseLibrary( tmp );
  42.           return FALSE;
  43.         }
  44.        else return TRUE;
  45.      }
  46.     else return FALSE;
  47.   }
  48. ...
  49. if ( !taskOpenLibrary( "intuition.library", 0, &IntuitionBase ) )
  50.    die_gracefully("Libraries, they are a changin'");
  51.  
  52. >I can't imagine that C= will create libraries which must be opened for each
  53. >process. Rendering many programs incompatible?
  54.  
  55. Commodore already says that each task/process must open it's libraries
  56. for itself.  The above example will at least let your programs be
  57. aware that they have become incompatible.  Otherwise, I don't see
  58. how CreateTask() and friends are of much value for C programs if
  59. the tasks created need to call library functions.
  60. --
  61.  _/_/_/  _/     Todd_Lewis@unc.edu          You can lead a horse to 
  62.   _/    _/     utoddl@guitar.oit.unc.edu   Mohammad, but you can't make
  63.  _/    _/_/_/                             a mountain drink a mole hill.
  64.