home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / s / s001 / 1.ddi / TS / ASM / SSLEEP.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-08-09  |  1.3 KB  |  52 lines

  1. ;                **************
  2. ;                * SSLEEP.asm *
  3. ;               *******************************************
  4. ;               * Copyright TimeSlice, Inc. 1985, 86, 87. *
  5. ;               *******************************************
  6. ;
  7. include ts.inc
  8. ;
  9. ;
  10. start_data
  11. end_data
  12. ;
  13. ;
  14. extrn    __jaddr:far
  15. extrn    __jmpint:far
  16. ;
  17. start_code
  18. ;
  19. ;
  20. ;*******
  21. ;* SSLEEP()
  22. ;* Ssleep() puts the slicer to sleep. This routine is invoked by a process
  23. ;* which does not want to be interrupted by the slicer. The slicer stays
  24. ;* asleep until SWAKE() is called as many times as SSLEEP() was invoked.
  25. ;* This level of slicer sleep nesting is kept in _SSLEV.
  26. ;* The method used to put the slicer to sleep involves modifying the slicer's
  27. ;* first instruction so that it causes a jump to the original timer service
  28. ;* routine. 
  29. ;*******
  30. routine    ssleep
  31.     pushf            ;save flags
  32.     push    es        ;and ES
  33.     cli            ;No interrupts allowed
  34.     mov    ax,_sslev    ;AX <-- current level of slicer sleep
  35.     test    ax,ax        ;already asleep ???
  36.     jnz    ss1        ;yes, simply inc _sslev
  37.     mov    bx,offset __jaddr
  38.     mov    dx,seg __jaddr
  39.     mov    es,dx
  40.     mov    cx,es:[bx].off    ;copy original inter routine...
  41.     mov    dx,es:[bx].sgt
  42.     mov    bx,offset __jmpint
  43.     mov    es:[bx].off,cx    ;...at jmpint
  44.     mov    es:[bx].sgt,dx
  45. ss1:    inc    ax        ;increment level of slicer sleep
  46.     mov    _sslev,ax
  47.     pop    es        ;restore ES
  48.     popf            ;and flags
  49. return    ssleep
  50. ;
  51. end_code
  52.