Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
4.6 KiB

  1. MACPRINT SPOOLER CDD
  2. Design Goals:
  3. MacPrint is ported from the OS/2 implementation. The primary design
  4. goal is to simplify the porting process as much as possible. The
  5. original structure of MacPrint was retained and modified only where
  6. necessary. There are 3 main areas of modification:
  7. * configuration
  8. * synchronization
  9. * removal of the despooler component
  10. * support for cached dictionaries
  11. configuration changes -
  12. Where the OS/2 implementation depended on being able to determine
  13. at service start time the configuration for all possible shared
  14. print queues (this was read from lanman.ini), the NT implementation
  15. allows for the dynamic addition and removal of printer objects
  16. without specifying configuration information in a data file. This
  17. forced the modification of the main queue list structure to be
  18. a single linked list instead of an array. In the NT implementation,
  19. there is now a single data structure for NT printer objects, and
  20. being in this structure implies the existence of a validly configured
  21. NT Printer Object.
  22. All of the code to read and parse configuration information from
  23. LANMAN.INI at service start time was removed and replaced by code
  24. to get configuration information from the EnumPrinters() API as new
  25. printers are discovered.
  26. synchronization changes -
  27. NT provides a more robust synchronization mechanism than OS/2.
  28. WaitForMultipleObjects() actually works correctly under NT, and
  29. it is possible to wait on objects besides semaphores. Mutual
  30. exclusion to data is achieved through critical sections as opposed
  31. to mutexes or semaphores. Critical sections require fewer resources
  32. than either, but can only be shared between threads of the same
  33. process. Events are used to process jobs asynchronously. Instead
  34. of clearing a semaphore when a read or open occurs, an event is
  35. signaled. Semaphores in NT are used as a gating mechanism,
  36. and are not designed to be used as a signaling mechanism. Syncronization
  37. with the termination of threads is achieved by waiting on the thread
  38. object as opposed to waiting on an event that the thread signals
  39. just before it terminates.
  40. removal of the despooler -
  41. The spooler and despooler were somewhat integrated in the OS/2
  42. implementation - especially with regards to configuration information.
  43. Data structures pertinent to the despooler only were removed, and
  44. the configuration routines are no longer contained in a DLL shared
  45. by the spooler and despooler. The only connection between the two
  46. components is now through a PostScript comment that is included by
  47. the spooler to indicate if ctrl-d's should be stripped by the
  48. despooler.
  49. support for cached dictionaries -
  50. As the caching of PostScript dictionaries achieved only modest performance
  51. improvements at best, and since it added significant complexity to the
  52. code, support for cached dictionaries will most likely be removed in
  53. the NT implementation. If at coding time it becomes clear that more
  54. work is involved to remove the feature than to port it, it may stay
  55. in.
  56. Thread/Process Structure:
  57. MacPrint is an NT Service, hence it follows the NT Service Model. main()
  58. is the service control dispatcher for the MacPrint service. This thread
  59. is used by the NT Service Controller to communicate with the MacPrint
  60. Service.
  61. MacPrintMain() is the main thread for MacPrint. It is responsible for
  62. monitoring the NT Print Manager for configuration changes (creation
  63. and removal of printer objects) and for starting and stopping threads
  64. to manage each NT Printer Object. Essentially, MacPrintMain polls
  65. until a service stop request is received. While polling, it enumerates
  66. printers from the NT Print Manager and either creates a control thread
  67. for a newly discovered printer or terminates the control thread for
  68. each printer no longer configured.
  69. QueueServiceThread() is the thread for each active NT Printer Object.
  70. This thread listens for jobs directed to the NT printer and processes
  71. the job. One thread supports multiple jobs for the printer. This is
  72. done by using two events per queue - ReadEvent and OpenEvent. The
  73. PAP API have the property that they take an address to store a completion
  74. code when the event completes, and this address is specified to be in
  75. a per job data structure. The event is common for all jobs in the
  76. queue. When a particular event is signaled, the list of pending jobs
  77. in that queue is walked to find one that is in the correct state
  78. (read_pending or open_pending) and that has it's completion code set.
  79. The event is processed for that job, and the job is moved to the end
  80. of the list so that events for jobs are processed in round-robin
  81. order.