add a realtime scheduler class and priority-inheritance mutexes with timeouts and abandonment, add an HDA audio driver and a SYS_AUDIO_* syscall family, flesh out kernel32 with Win32 threads, events, mutexes, critical sections, and condition variables, add SYS_RESUME_THREAD for suspended thread creation, add KeInitializeMemoryTypes to reprogram MTRRs and install a canonical PAT for WB/WC/UC control, rework the display pipeline with a pitched present path and console output flush, bring back disk.vhd with mtools since vvfat fucking sucks, harden AHCI with serialized cache flush, USB mass storage with SCSI sense-data decoding, and xHCI with cleaner DMA teardown, fix the last stray for(;;) in HalStopProcessor to while(true), pile on smoke tests for audio, win32 sync primitives, and thread suspend, implement AHCI timeout, kill readahead since it was desperetaly trying to murder me, fix doom sound x2.
This commit is contained in:
1 parent
8b254f84f4
commit
4add6789ba
177 files changed
+22565
-3070
No files matched your search
@@ -0,0 +1,97 @@
|
||||
// Win32 suspended-thread creation and resume smoke test.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <ntlite/syscall.h>
|
||||
|
||||
typedef void* HANDLE;
|
||||
typedef unsigned long DWORD;
|
||||
typedef int BOOL;
|
||||
typedef DWORD (__stdcall *THREAD_START_ROUTINE)(void* parameter);
|
||||
|
||||
#define CREATE_SUSPENDED 0x00000004u
|
||||
#define INFINITE 0xFFFFFFFFu
|
||||
#define WAIT_OBJECT_0 0u
|
||||
#define INVALID_HANDLE_VALUE ((HANDLE)(intptr_t)-1)
|
||||
|
||||
__declspec(dllimport) HANDLE CreateThread(void* attributes,
|
||||
size_t stackSize,
|
||||
THREAD_START_ROUTINE startRoutine,
|
||||
void* parameter,
|
||||
DWORD creationFlags,
|
||||
DWORD* threadId);
|
||||
__declspec(dllimport) DWORD ResumeThread(HANDLE thread);
|
||||
__declspec(dllimport) DWORD WaitForSingleObject(HANDLE handle, DWORD milliseconds);
|
||||
__declspec(dllimport) void Sleep(DWORD milliseconds);
|
||||
__declspec(dllimport) BOOL CloseHandle(HANDLE handle);
|
||||
|
||||
static volatile long gStarted;
|
||||
static volatile long gRelease;
|
||||
|
||||
// Writes one test message to the native console.
|
||||
static void print(const char* text) {
|
||||
SYS_WRITE_CONSOLE_REQUEST request = { SysSvFromCstr(text) };
|
||||
(void)SysWriteConsole(&request);
|
||||
}
|
||||
|
||||
// Terminates the test after one contract failure.
|
||||
static void fail(const char* message) {
|
||||
print("win32_thread_suspend_smoke: ");
|
||||
print(message);
|
||||
print("\n");
|
||||
while (true) (void)SysExitProcess(1);
|
||||
}
|
||||
|
||||
// Records that the suspended worker reached its user entry point.
|
||||
static DWORD __stdcall suspended_worker(void* parameter) {
|
||||
(void)parameter;
|
||||
gStarted = 1;
|
||||
while (!gRelease)
|
||||
Sleep(1u);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Exits immediately so process teardown can retain its thread handle.
|
||||
static DWORD __stdcall exited_worker(void* parameter) {
|
||||
(void)parameter;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Verifies that CREATE_SUSPENDED prevents execution until ResumeThread.
|
||||
int main(void) {
|
||||
print("win32_thread_suspend_smoke: begin\n");
|
||||
|
||||
DWORD threadId = 0;
|
||||
HANDLE thread = CreateThread(NULL, 0, suspended_worker, NULL,
|
||||
CREATE_SUSPENDED, &threadId);
|
||||
if (!thread || thread == INVALID_HANDLE_VALUE || threadId == 0)
|
||||
fail("CreateThread(CREATE_SUSPENDED) failed");
|
||||
|
||||
Sleep(25u);
|
||||
if (gStarted)
|
||||
fail("worker ran before ResumeThread");
|
||||
|
||||
if (ResumeThread(thread) != 1u)
|
||||
fail("first ResumeThread did not return one");
|
||||
if (ResumeThread(thread) != 0u)
|
||||
fail("second ResumeThread did not return zero");
|
||||
|
||||
gRelease = 1;
|
||||
if (WaitForSingleObject(thread, INFINITE) != WAIT_OBJECT_0)
|
||||
fail("worker wait failed");
|
||||
if (!gStarted)
|
||||
fail("worker did not run after ResumeThread");
|
||||
if (!CloseHandle(thread))
|
||||
fail("CloseHandle failed");
|
||||
|
||||
// Keep one completed thread handle open until process exit. Dead THREAD
|
||||
// objects may remain waitable, but they must not keep the process alive.
|
||||
HANDLE retained = CreateThread(NULL, 0, exited_worker, NULL, 0, NULL);
|
||||
if (!retained || retained == INVALID_HANDLE_VALUE)
|
||||
fail("retained CreateThread failed");
|
||||
if (WaitForSingleObject(retained, INFINITE) != WAIT_OBJECT_0)
|
||||
fail("retained worker wait failed");
|
||||
|
||||
print("win32_thread_suspend_smoke: PASS\n");
|
||||
while (true) (void)SysExitProcess(0);
|
||||
}
|
||||
Reference in new issue
Block a user