Commit graph

29 commits

Author SHA1 Message Date
Alex Ionescu
3a24f9a505 - Set the right Thread->WaitTime dring waits
- Initialize WaitBlock->Thread during thread creation.
- Make APCs queuable for the thread after it's created
- Enable Timer Block optimization since it works now. This allows us not to always set-up for each wait, since most of its fields can remain static.
- Properly link wait block together with the waitlist of the timer.

svn path=/trunk/; revision=20632
2006-01-06 22:57:21 +00:00
Alex Ionescu
92f9f2e23b - Invert CONFIG_SMP defines as requested by Hartmut
- Remove KiBlockThread and replace by more elegant KiSwapThread which will also make moving to the new scheduler easier.
- Handle special case where we have kernel apcs pending and your previous irql was below apc_level during the wait code.
- Remove hack to manually unwait a thread during a status of kernel apc.

svn path=/trunk/; revision=20605
2006-01-06 08:00:09 +00:00
Alex Ionescu
c1b51155f7 - Fix some bugs in Kernel Queue implementation:
* KeRemoveQueue did not set Thread->WaitNext = FALSE if it was called with WaitNext = TRUE.
  * KeRemoveQueue did not handle the case where a kernel-mode APC is pending and the previous IRQL was below APC_LEVEL.
  * KeRemoveQueue did not set the thread's wait status to 0.
  * KiInsertQueue did not set the Thread's wait status to the entry being inserted.
  * KiInsertQueue did not remove the thread from its wait list.
  * KeRemoveQueue did not properly link the wait blocks.

svn path=/trunk/; revision=20601
2006-01-06 02:25:12 +00:00
Gunnar Dalsnes
b890e50a9e -reorder InsertXscendingOrder macro argument order and update uses
-start to macrofy list enums in ntoskrnl using LIST_FOR_EACH macros
-use IsListEmpty some places instead of manual coding
-profile.c:KeStartProfile() zero correct buffer in (and not the NULL ptr;-)
-improve LIST_FOR_EACH macros so that the iterator is set to NULL at end of enum
-kthread.c:KiServiceCheck() set the shadowtable before calling the win32k proc/thread init funcs
-apc.c:KiInsertQueueApc() insert special apcs in correct fifo order 
-apc.c:KeFlushQueueApc() simplify 
-timer.c:KiExpireTimers() calling RemoveEntryList on a possibly empty list is not ok

svn path=/trunk/; revision=18113
2005-09-26 22:57:48 +00:00
Hartmut Birr
b10d2b80c1 Fixed the return value in KeRundownQueue if the queue is empty. This should fix bug 751.
svn path=/trunk/; revision=17622
2005-09-03 18:00:54 +00:00
Thomas Bluemel
5e348c00c1 - use inlined probing macros for basic types
- minor optimizations by comparing the processor mode against KernelMode (==0) instead of UserMode (==1)

svn path=/trunk/; revision=17467
2005-08-21 19:04:23 +00:00
Steven Edwards
e4be245882 strip whitespace from end of lines
svn path=/trunk/; revision=15164
2005-05-09 01:38:29 +00:00
Alex Ionescu
9d6033ebad Fix WaitAll bug. Previously, not all Wait Objects in a WaitAll were checked for signaling, which meant as soon as one was signaled, all were supposed to be satisfied. Worse however, only one object would get satisfied anyways, because of a second bug which hid the first during my testing. Now, all wait all objects must be signaled before satsifcation, and satisfaction is correctly done on all the objects. Reg tested with multithrdwin, which did not properly work before. Thanks to w3seek for notifying me of this bug.
svn path=/trunk/; revision=14638
2005-04-16 17:48:46 +00:00
Alex Ionescu
eb54434d27 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
2005-03-18 05:53:04 +00:00
Alex Ionescu
8b97b835f2 Support Priority Boosting during Wait Satisfaction and Thread Abortion, and use it where necessary. Should provide a bit more responsiveness.
svn path=/trunk/; revision=14049
2005-03-14 06:44:31 +00:00
Alex Ionescu
6a7ba78c91 Dispatching & Queue Rewrite II:
- Rewrote wait code. It is now cleaner, more optimized and faster. All waiting
      functions are now clearly differentiated instead of sharing code. These functions
      are called up to a dozen times a second, so having dedicated code for each of
      them is a real boost in speed.
    - Fixed several queue issues, made a dedicated queue wait/wake function (you are not
      supposed to use KeWaitFor on a queue, and this is also a speed boost), and make it
      compatible with new wait code.
    - Optimized Work Queue code to be much smaller and better organized, by using an 
      array instead of hard-coded multiple static variables. Also, add support for the
      real NT structures and implementation, paving the road for Dynamic Work Items, which
      also have timeouts, and deadlock dection + debug info.
    - Simplified PsBlockThread and made it compatible with wait code.
    - Added support for priority boosting when unwaiting a thread; will use later, as well
      as put proper boosting for dispatch objects.
    - Inlined all dispatcher lock functions and header initialization for speed.
    - Moved executive wait code into ob.

svn path=/trunk/; revision=14047
2005-03-14 05:54:32 +00:00
Thomas Bluemel
cfdb595cc6 Alex Ionescu <ionucu@videotron.ca>
Dispatcher Objects Rewrite (minus Queues, coming in next patch).
	Global Changes:
 
		- Use KOBJECT enumerations for all objects, remove obsoleted ros-internal enumeration.
		- Reformatting, commenting, and addition of Debug Prints for easier debugging
		- Properly create Executive Objects. They don't need a creation routine.
		- Make sure to properly lock and release the Dispatcher Database.
 
	Mutex/Mutant:
 
		- Correct MUTANT_BASIC_INFORMATION
		- Return previous state in Kernel Functions, intead of 1 or 0 all the time.
		- Initialize listhead properly
		- Removed code duplication between mutant and mutex release.
		- Fix bugs in release
		- Add proper exeption if the mutex is not owned.
 
	Kernel Queues:
 
		- Optimize the code
		- Use Inserted Flag
 
	Timers:
 
		- Some changes in setting the default data to allow KiInsertTimer to be called internally 
		  by the wait code in the next patch.
 
	Events:
 
		- Optimize and simplify KeInitializeEvent
		- Implement KeInitializeEventPair
		- Fix KePulseEvent. It was completely messed up and also used unneeded Interlocked function.
		- Fix KeResetEvent. It was not locking the dispatcher lock but using Interlocked.
		- Fix KeSetEvent. It was not differentiating between Notification and Sycronization events 
		  and also signaling the Event even if nobody was waiting on it.
 
	Semaphores:
 
		- Fix KeReleaseSemaphore. It was not checking if nobody was waiting on it before unwaiting the thread.
		- Fix not releasing dispatcher database before raising an exception.
		- Add check to NtCreateSemaphore to make sure the counts make sense.
 
	Event Pairs:
 
		- Remove Thread Event Pair. They are only used for NT4 QuickLPC which is obsoleted.
		- Use KeInitializeEventPair

svn path=/trunk/; revision=14045
2005-03-14 02:08:17 +00:00
Alex Ionescu
db4c78ea86 Reverting to 13775. Sorry for the mess. This is dedicated to Jane! 19934415.
svn path=/trunk/; revision=13777
2005-02-28 17:40:15 +00:00
Alex Ionescu
ecfad8ec74 Test commit. Not official branch release -- it will follow shortly in 15 minutes. If this ends up in HEAD i will revert immediately (i have svn switched so it shouldn't)
svn path=/trunk/; revision=13776
2005-02-28 16:44:38 +00:00
Alex Ionescu
fe6116543e Standardize comment headers. Patch by Trevor McCort
svn path=/trunk/; revision=13311
2005-01-26 13:58:37 +00:00
Filip Navara
e6464bc179 Basic support for priority boosting.
svn path=/trunk/; revision=12965
2005-01-12 13:43:05 +00:00
Martin Fuchs
e228aadfe5 migrate substitution keywords to SVN
svn path=/trunk/; revision=12852
2005-01-06 13:58:04 +00:00
Gunnar Dalsnes
0c5a9ba4f5 fix kernel queues + misc fixes/cleanups
svn path=/trunk/; revision=11754
2004-11-21 18:33:54 +00:00
Casper Hornstrup
1bf0775833 2004-08-15 Casper S. Hornstrup <chorns@users.sourceforge.net>
* ntoskrnl/include/.cvsignore: New file.
	* ntoskrnl/include/ntoskrnl.h: Ditto.
	* ntoskrnl/*/*.c: Use pre-compiled header.
	* ntoskrnl/Makefile: Support pre-compiled header.
	* tools/helper.mk: .pch files are now .gch files.

svn path=/trunk/; revision=10550
2004-08-15 16:39:12 +00:00
Eric Kohl
df0af98c1b Reimplemented dispatcher database lock and synchronization primitives.
This fixes bug #26.

svn path=/trunk/; revision=6502
2003-11-02 01:16:21 +00:00
Andrew Greenwood
8535425fcd ReactOS W32API convert part 4
I've modified ReactOS' headers and source files to match W32API's headers, and fully recompiled and booted ReactOS without them, so it does still work.

A more detailed log of changes will be sent to the ros-kernel mailing list shortly.

svn path=/trunk/; revision=5572
2003-08-14 18:30:28 +00:00
Royce Mitchell III
59d5c9f016 finished applying @implemented and @unimplemented comments and remove the comments from non-api functions
svn path=/trunk/; revision=5068
2003-07-11 01:23:16 +00:00
Royce Mitchell III
7fc8c17d16 @implemented and @unimplemented comments for ntoskrnl/ke/*.c
svn path=/trunk/; revision=5044
2003-07-10 17:44:06 +00:00
Casper Hornstrup
922b9fdf46 2003-06-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
Changes for compiling with w32api

	* include/ddk/cctypes.h (PREACTOS_COMMON_FCB_HEADER): Remove.
	(FSRTL_COMMON_FCB_HEADER): Add.
	* include/ddk/iotypes.h (FILE_OBJECT): Rename field
	SectionObjectPointers to SectionObjectPointer.
	* ntoskrnl/cc/copy.c, ntoskrnl/cc/misc.c, ntoskrnl/cc/pin.c,
	ntoskrnl/cc/view.c, ntoskrnl/io/rawfs.c, ntoskrnl/mm/section.c,
	drivers/fs/cdfs/cleanup.c, drivers/fs/cdfs/fcb.c,
	drivers/fs/cdfs/fsctl.c, drivers/fs/ntfs/fcb.c, drivers/fs/ntfs/fsctl.c,
	drivers/fs/vfat/close.c, drivers/fs/vfat/create.c,
	drivers/fs/vfat/finfo.c, drivers/fs/vfat/fcb.c, drivers/fs/vfat/fsctl.c:
	Use new	FILE_OBJECT structure.
	* drivers/fs/cdfs/cdfs.h, drivers/fs/ntfs/ntfs.h, drivers/fs/vfat/vfat.h:
	Use new FSRTL_COMMON_FCB_HEADER structure.
	* drivers/net/afd/include/afd.h (FSRTL_COMMON_FCB_HEADER): Remove.
	* include/ddk/ketypes.h (KQUEUE): Match w32api structure.
	* ntoskrnl/ke/queue.c, ntoskrnl/ke/wait.c: Use new structure.
	* ntoskrnl/ke/spinlock.c (KeAcquireSpinLockAtDpcLevel,
	KeReleaseSpinLockFromDpcLevel): Undefine before declaring.

svn path=/trunk/; revision=4865
2003-06-07 11:34:36 +00:00
Gunnar Dalsnes
957f814a24 initial work on I/O completion
svn path=/trunk/; revision=4352
2003-03-19 23:17:52 +00:00
Casper Hornstrup
d8acda7c3e 2002-11-10 Casper S. Hornstrup <chorns@users.sourceforge.net>
* include/defines.h: Fix warnings when bulding with gcc 3.3.
	* include/ddk/status.h: Ditto.
	* include/freetype/internal/ftdebug.h: Ditto.
	* include/net/ndis.h: Ditto.
	* lib/msafd/misc/helpers.c: Ditto.
	* lib/user32/windows/defwnd.c: Ditto.
	* lib/user32/windows/window.c: Ditto.
	* ntoskrnl/cm/ntfunc.c: Ditto.
	* ntoskrnl/cm/regfile.c: Ditto.
	* ntoskrnl/cm/regobj.c: Ditto.
	* ntoskrnl/dbg/errinfo.c: Ditto.
	* ntoskrnl/ex/hashtab.c: Ditto.
	* ntoskrnl/include/internal/mm.h: Ditto.
	* ntoskrnl/io/irp.c: Ditto.
	* ntoskrnl/kd/gdbstub.c: Ditto.
	* ntoskrnl/ke/queue.c: Ditto.
	* ntoskrnl/ke/sem.c: Ditto.
	* ntoskrnl/ldr/resource.c: Ditto.
	* ntoskrnl/mm/balance.c: Ditto.
	* ntoskrnl/mm/freelist.c: Ditto.
	* ntoskrnl/mm/mdl.c: Ditto.
	* ntoskrnl/mm/npool.c: Ditto.
	* ntoskrnl/mm/section.c: Ditto.
	* ntoskrnl/rtl/error.c: Ditto.
	* ntoskrnl/rtl/mem.c: Ditto.
	* ntoskrnl/rtl/string.c: Ditto.
	* ntoskrnl/rtl/time.c: Ditto.
	* ntoskrnl/rtl/unicode.c: Ditto.
	* ntoskrnl/rtl/wstring.c: Ditto.
	* ntoskrnl/rtl/i386/exception.c: Ditto.
	* subsys/win32k/freetype/src/base/ftinit.c: Ditto.

svn path=/trunk/; revision=3738
2002-11-10 18:17:43 +00:00
Casper Hornstrup
17c0b5798e Reverted latest changes.
svn path=/trunk/; revision=3473
2002-09-08 10:23:54 +00:00
Casper Hornstrup
387d432884 Use free Windows DDK and compile with latest MinGW releases.
svn path=/trunk/; revision=3466
2002-09-07 15:13:13 +00:00
Eric Kohl
0d5652813b Started kernel queue implementation.
Added win32k support functions.

svn path=/trunk/; revision=2483
2002-01-04 13:09:37 +00:00