cow3.txt
上传用户:xiaoan1112
上传日期:2013-04-11
资源大小:19621k
文件大小:4k
源码类别:

操作系统开发

开发平台:

Visual C++

  1. Introduction
  2. This document describes implementation details of modules of CW.
  3. Applications should not depend upon anything contained herein.
  4. SWAPPING
  5. --------
  6. The CODE SWAPPING/LRU scheme used by CW is significantly different than
  7. Windows.
  8. The concepts as used in CW are described below and notably how they differ
  9. from Windows.
  10. This is not an attempt to document the Windows system.
  11. THUNKS
  12. ------
  13. The thunks used for CW are shorter (6 vs 10 bytes) than Windows,
  14. do not require the INT 3FH handler
  15. and implement a more efficient form of LRU.
  16. Noteably the SAR CS:[xxxx],1 instruction is not present in CW
  17. Thunks may take one of three forms:
  18. FORM 1 (ENTMOVE) : Resident code segment.
  19. JMPF seg:off
  20. DB segno
  21.   -- action of jumping to thunk:
  22. jump to resident program
  23. FORM 2 (ENTMOVE1) : Resident 
  24. CALLN relative to JMPF RelruSegment
  25. DW offset
  26. DB segno
  27.   -- action of jumping to thunk:
  28. update LRU for segment, change ENTMOVE1 -> ENTMOVE
  29. then jump to resident program
  30. FORM 3 (ENTMOVE2) : Not-resident
  31. CALLN relative to JMPF RelruSegment
  32. DW offset
  33. DB segno
  34.   -- action of jumping to thunk:
  35. load in segment, change ENTMOVE1 -> ENTMOVE
  36. then jump to resident program
  37. LRU
  38. ---
  39. LRU for discardable (i.e. moveable) code segments is defined completely
  40. by the segment reference bytes (1 per code segment).
  41. The following values for these bytes are used:
  42. 0 - Most recently used
  43. 1..0x7f - less recently used
  44. 0x80 - non-resident (i.e. discarded) code segment
  45. 0xFF - FIXED segment
  46. The "ReLru" process only occurs for resident segments (i.e. segrefbyte <= 0x7f).
  47. This consists of setting the proper segrefbyte to 0 indicating that this
  48. segment is the Most Recently Used segment. The "Relru" process is initiated
  49. by the program calling a thunk of FORM2.
  50. The "Sweep" process occurs periodically (currently about every 1/4 of a second)
  51. and asynchronously to the main program.
  52. The "Sweep" process consists of bumping the segref bytes in the range 0 .. 0x7e
  53. (this keeps 0x7f .. 0xff from being changed), and going through the entry
  54. table (i.e. the list of thunks) and changing ENTMOVE (FORM1) to ENTMOVE (FORM2)
  55. thunks.
  56. Question : Why are we doing this ?
  57. Answer : the Window's LRU system puts a SAR CS:[xxxx],1 instruction at the
  58. start of each thunk (requiring 31 cycles on an 8088 - more than tripling the
  59. time it takes for a thunk).
  60. So far all the changes in the LRU scheme have been improvements over the
  61. Windows LRU. The thing involved with LRU is the determination of which
  62. segments are the least recently used. This is where the CW system suffers
  63. (i.e. is less efficient than Windows). In windows (due to the fact Windows
  64. updates a linked LRU list) it is just a matter of removing the head item
  65. from the lru linked list. For CW the extra work of scanning the array
  66. of segref bytes is needed.
  67. This should happens relatively rarely (i.e. over a long session,
  68. each discard will correspond to re-reading in the code -
  69. making this an already slow process).
  70. RETURN THUNKS
  71. -------------
  72. Return thunks are also dissimilar from Windows.
  73. First, they are of a different form (ENTRET) :
  74. CALLN relative to JMPF ReturnThunk
  75. DB segno
  76. DW offset
  77. Note : these are kept in a table (pretthunks). There is one per code segment
  78. (even for FIXED segments, in which case it is not used).
  79. The segno is the segment number (and is used since dividing by 5 is slow on
  80. the 8086).
  81. The offset is either -1 (0xffff) or a valid offset:
  82. if offset == 0xffff then this means that either:
  83. a) the segment is resident
  84.    or   b) the segment is not resident, and there are no returns
  85. to that segment on the stack.
  86. if offset != 0xffff then this means that the segment IS NOT resident
  87. AND the