diff options
Diffstat (limited to 'uisimulator/win32/thread-win32.c')
-rw-r--r-- | uisimulator/win32/thread-win32.c | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/uisimulator/win32/thread-win32.c b/uisimulator/win32/thread-win32.c deleted file mode 100644 index 7c33017c7e..0000000000 --- a/uisimulator/win32/thread-win32.c +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Felix Arends | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #define WINDOWS_LEAN_AND_MEAN | ||
21 | #include <windows.h> | ||
22 | #include <time.h> | ||
23 | #include "thread-win32.h" | ||
24 | #include "kernel.h" | ||
25 | #include "debug.h" | ||
26 | |||
27 | HANDLE lpThreads[256]; | ||
28 | int nThreads = 0, | ||
29 | nPos = 0; | ||
30 | long current_tick = 0; | ||
31 | CRITICAL_SECTION CriticalSection; | ||
32 | |||
33 | |||
34 | void yield(void) | ||
35 | { | ||
36 | LeaveCriticalSection(&CriticalSection); | ||
37 | Sleep(1); | ||
38 | EnterCriticalSection(&CriticalSection); | ||
39 | } | ||
40 | |||
41 | void sim_sleep(int ticks) | ||
42 | { | ||
43 | LeaveCriticalSection(&CriticalSection); | ||
44 | Sleep((1000/HZ) * ticks); | ||
45 | EnterCriticalSection(&CriticalSection); | ||
46 | } | ||
47 | |||
48 | DWORD WINAPI runthread (LPVOID lpParameter) | ||
49 | { | ||
50 | EnterCriticalSection(&CriticalSection); | ||
51 | ((void(*)())lpParameter) (); | ||
52 | LeaveCriticalSection(&CriticalSection); | ||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | int create_thread(void (*fp)(void), void* sp, int stk_size) | ||
57 | { | ||
58 | DWORD dwThreadID; | ||
59 | |||
60 | (void)sp; | ||
61 | (void)stk_size; | ||
62 | |||
63 | if (nThreads == 256) | ||
64 | return -1; | ||
65 | |||
66 | lpThreads[nThreads++] = CreateThread (NULL, | ||
67 | 0, | ||
68 | runthread, | ||
69 | fp, | ||
70 | 0, | ||
71 | &dwThreadID); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | void init_threads(void) | ||
77 | { | ||
78 | InitializeCriticalSection(&CriticalSection); | ||
79 | EnterCriticalSection(&CriticalSection); | ||
80 | } | ||