home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / sun / misc / 4018 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  3.7 KB

  1. Path: sparky!uunet!pipex!warwick!str-ccsun!strath-cs!gor@cs.strath.ac.uk
  2. From: gor@cs.strath.ac.uk (Gordon Russell)
  3. Newsgroups: comp.sys.sun.misc
  4. Subject: Lightweight Tasking
  5. Message-ID: <10393@baird.cs.strath.ac.uk>
  6. Date: 1 Sep 92 08:55:39 GMT
  7. Sender: gor@cs.strath.ac.uk
  8. Organization: Comp. Sci. Dept., Strathclyde Univ., Glasgow, Scotland.
  9. Lines: 61
  10.  
  11.  
  12.  Hello all SPARC gurus....
  13.  
  14.    I have an interesting problem with a (almost) portable lightweight
  15. thread management system on the SPARCs. What I have been working on is a
  16. simulator of a particular machine using the SPARCs, but I have to use a number
  17. of SPARC instructions per simulated instruction. Now, I also want to prevent
  18. task-switching during a simulated instruction (ie no simulated instruction can
  19. be interrupted). One way to do this using lwp would be to use a
  20. mon_enter(mon)...mon_exit(mon) combination around each of the pseudo
  21. instructions, but the simulation must be fast, and mon_enter has more executed
  22. instructions than those used to represent the simulated ones! Anyway, lwp
  23. is not very portable, so back to the drawing board.
  24.  
  25.    I design a system using SIGNAL and SETITIMER, with the aim of performing
  26. a context switch in the signal handler. Sounds great. I inhibit the
  27. ALRM signal by using SIGSETMASK (which is small). Now, when the ALARM
  28. signal is generated, I can context switch. Well I think I could, however
  29. a number of problems have arose, and I am hoping someone can help me with them:
  30.  
  31.  o the sigcontext structure does not contain the y register. Surely this is
  32.    a mistake. If so, what is the easiest way of rectifying this problem?
  33.  o the sigcontext structure contains a number of fields which are not explained
  34.    in the manual. Does someone have an explination (eg what is npc, the
  35.    next program counter)?
  36.  o Any good ways to set up a task initially? My approach is dire!
  37.  o Any way I can convince the compiler to pull in some library routines
  38.    as inline code (ie sigsetmask() ), as this would certainly improve the
  39.    performance significantly (although it is already a leaf procedure).
  40.  
  41. Incidentally, does anyone have any thoughts on an alternative approach?
  42. I would be happy to hear them, and I don't mind writing some code using
  43. the .il approach. 
  44.  
  45. One alternative scheme I have considered is to use one of the global
  46. registers, and set it to one when I enter a simulated instruction.
  47. On leaving, I perform an exchange on the register with a local register,
  48. setting the global reg to zero, and cheching the local reg. If it is
  49. one, then ok, but if it was zero, then the timer must have expired,
  50. so do an task switch.   In the timer handler, if the global register
  51. is zero, then ok to task switch, otherwise set the register to zero and return
  52. (thus allowing the instruction to instigate the switch). This is the
  53. most efficient scheme I know.
  54.  
  55. All help would be appreciated. This is for a research purposes only (I am not
  56. making money from it), and full acknowlegments will be given in my thesis
  57. (I am a PhD-er). Once this is working, I will post a message to the group
  58. allowing them to get a copy if they wish.
  59.  
  60.   Roll on solaris
  61.  
  62. PS I use vi all the time, and not just as a last resort... Its great!
  63.  
  64. +--------------------------------+-------------------------------------------+
  65. |  Gordon Russell                |  EMAIL     : gor@cs.strath.ac.uk          |
  66. |  L13.13a, Livingstone Tower,   |  TELEPHONE : 041-552-4400   Ex 3703       |
  67. |  University Of Strathclyde,    |  FAX       : 041-552-0775                 |
  68. |  26 Richmond Street,           +-------------------------------------------+
  69. |  Glasgow, G1 1XH               | Spelling mistakes within this document are|
  70. |  Scotland, UK                  | caused by internet compaction algorithms. |
  71. +--------------------------------+-------------------------------------------+
  72.