Thread/Process Termination/Repeaing Rewrite + Fixes
authorAlex Ionescu <aionescu@gmail.com>
Fri, 18 Mar 2005 05:53:04 +0000 (05:53 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Fri, 18 Mar 2005 05:53:04 +0000 (05:53 +0000)
commiteb54434d27655cef15048f708c06cd11d3637dd4
treee8bca33a302b194fd68a0e51f48be3074206b96d
parent604f4f13c1f8d079e60a173a7adca6ef7e1feed1
Thread/Process Termination/Repeaing Rewrite + Fixes
---------------------------------------------------

    - ps/cid.c:
            * Moved CID Lookup functions here

    - ps/security.c:
            * Moved all security related functions here. Makes other files neater and security functions
              easier to locate.

    - ps/thread.c:
            * Moved most of the Thread Scheduling/Dispatching code that belongs in the Kernel to /ke and
              renamed functions from Ps to Ki.
            * Implemented PsIsSystemThread.
            * Removed Reaper Thread Init (now obsolete).
            * Renamed PiDeleteThread to PspDeleteThread.
            * Moved Thread State functions from tinfo.c to here.

    - ps/process.c:
            * Removed Query/Set Process functions and moved to ps/query.c
            * Renamed PiDeletePRocess to PspDeleteProcess
            * Removed obsoleted Process Termination functions, moved persistent one to kill.c

    - ps/create.c:
            * Moved the security APIs to security.c
            * Correctly implemented PsCreateSystemThread to actually create system threads.

    - ps/suspend.c
            * Rewrote Nt Executive functions to use Kernel functions.
            * Moved Ps* Routines into ke/kthread.c and fixed them. The implementation was wrong in
              some aspects, especially the issue of the APC looping around the KeWaitXxx call and the
              fact that the routines excluded/ignored the FreezeCount.

    - ps/debug.c
            * Fixed completely broken implementation of Get/SetThreadContext. The old version crashed
              when called and did not work at all. Suspend Regression test now works.
            * Moved Context<->TrapFrame functions to ke/i386/
            * Combined Set/GetThreadContext APCs into a single one, and used special context structure.

    - ps/query.c:
            * Moved Thread/Process Query/Set Routines here.

    - ps/tinfo.c:
            * Removed.

    - ps/kill.c
            * Removed complicated Process Termination semantics and useless Attach/Detach in favor for
              a much more lightweight function which performs the same tasks as before and actually works.
              TaskManager can now terminate foreign processes.
            * Rewrote Thread Reaping to use the HyperCritical Work Queue instead of manually controlled
              thread. This results in much less code as well as an increase in speed and less micro
              management. The reaper is PspReapRoutine. Closing CMD.EXE now works properly without
              requiring masks that were added as hacks to allow it.
            * Renamed PiTerminateProcessThreads to PspTerminateProcessThreads. Fixed it to work with new
              termination code.
            * Added PspDeleteProcess to handle Process Object deletion. Kills the CID Handle here as done
              by Hartmut.
            * Added PspDeletethread here.
            * Renamed and rewrote PsTerminateCurrentThread to PspExitThread. Used NT Implementation out-
              lined in Windows Internals, Chapter 13. Uses less locks, a more concise order of actions,
              actually parses the Termination Ports, handles Dbgk notification. Timers are now rundown,
              and Mutex rundown is in a dedicated Kernel function. Final termination handled by KeTerminate
              Thread as documented.
            * Renamed PsTerminateOtherThread to PspTerminateThreadByPointer and modified implementation to
              be compatible with the changes above.
            * Renamed and regrouped Process Termination into PspExitProcess. Also implemented as described
              above, and moved each subsystem specific termination helper into its own subsytem.
            * Improved NtTerminateProcess and added more debugging messages.
            * Improved NtTerminateThread and added check against System Thread and made it compatible with
              new implementation.
            * Corrected PsTerminateSystemThread now that we support System Threads.
            * Corrected NtRegisterThreadTerminatePort to use same structure name as on windows for the
              port, and added tag to pool allocation (documented in pooltag.txt)

    include/internal/*.h:

            * Defined Scheduler Functions and misc new functions or renamed functions.

    ke/apc.c:

            * Fixed critical bug where APCs were not delivered at all if the thread wastion and cancels any timers that are associated
              to a thread, as well as their APCs and DPCs.

    REGRESSIONS FOUND: NONE

    BUGS/REGRESSIOSN FIXED:
                * Thread/Get Set Context now works.
                * Suspend Regression test now works.
                * Task manager can now kill foreign processes, even hung ones (like it should).
                * ExitProcess/closing cmd.exe with the 'x' button now works correctly without hacks.
      KNOWN ISSUES: I left a bit of a mess in the headers and some stuff still needs to be moved into the right
                  places. I just wanted to have this first part ready first, so that it won't get too big.

svn path=/trunk/; revision=14174
30 files changed:
reactos/ntoskrnl/Makefile
reactos/ntoskrnl/cm/ntfunc.c
reactos/ntoskrnl/ex/timer.c
reactos/ntoskrnl/include/internal/ex.h
reactos/ntoskrnl/include/internal/ke.h
reactos/ntoskrnl/include/internal/ob.h
reactos/ntoskrnl/include/internal/port.h
reactos/ntoskrnl/include/internal/ps.h
reactos/ntoskrnl/ke/apc.c
reactos/ntoskrnl/ke/dpc.c
reactos/ntoskrnl/ke/i386/exp.c
reactos/ntoskrnl/ke/i386/tskswitch.S
reactos/ntoskrnl/ke/kthread.c
reactos/ntoskrnl/ke/main.c
reactos/ntoskrnl/ke/process.c
reactos/ntoskrnl/ke/queue.c
reactos/ntoskrnl/ke/wait.c
reactos/ntoskrnl/ob/handle.c
reactos/ntoskrnl/ps/cid.c
reactos/ntoskrnl/ps/create.c
reactos/ntoskrnl/ps/debug.c
reactos/ntoskrnl/ps/idle.c
reactos/ntoskrnl/ps/kill.c
reactos/ntoskrnl/ps/process.c
reactos/ntoskrnl/ps/psmgr.c
reactos/ntoskrnl/ps/query.c [new file with mode: 0644]
reactos/ntoskrnl/ps/security.c [new file with mode: 0644]
reactos/ntoskrnl/ps/suspend.c
reactos/ntoskrnl/ps/thread.c
reactos/ntoskrnl/ps/tinfo.c [deleted file]