Last change
on this file was 209, checked in by umoeller, 23 years ago |
Dialog formatter rewrite.
|
-
Property svn:eol-style
set to
CRLF
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
2.9 KB
|
Line | |
---|
1 |
|
---|
2 | #define INCL_DOSMODULEMGR
|
---|
3 | #define INCL_DOSPROCESS
|
---|
4 | #define INCL_DOSEXCEPTIONS
|
---|
5 | #define INCL_DOSSESMGR
|
---|
6 | #define INCL_DOSQUEUES
|
---|
7 | #define INCL_DOSSEMAPHORES
|
---|
8 | #define INCL_DOSMISC
|
---|
9 | #define INCL_DOSDEVICES
|
---|
10 | #define INCL_DOSDEVIOCTL
|
---|
11 | #define INCL_DOSERRORS
|
---|
12 | #include <os2.h>
|
---|
13 |
|
---|
14 | #include <stdlib.h>
|
---|
15 | #include <string.h>
|
---|
16 | #include <stdio.h>
|
---|
17 |
|
---|
18 | #pragma hdrstop
|
---|
19 |
|
---|
20 |
|
---|
21 | #define HF_STDOUT 1
|
---|
22 |
|
---|
23 | #define LIMIT 2000
|
---|
24 |
|
---|
25 | typedef struct _THREAD
|
---|
26 | {
|
---|
27 | PCSZ pcszThreadName;
|
---|
28 | ULONG ulPrtyClass,
|
---|
29 | ulPrtyDelta;
|
---|
30 | CHAR szMsg[10];
|
---|
31 | TID tid;
|
---|
32 | } THREAD, *PTHREAD;
|
---|
33 |
|
---|
34 | /*
|
---|
35 | *@@ Print:
|
---|
36 | * writes the given string to stdout.
|
---|
37 | */
|
---|
38 |
|
---|
39 | VOID Print(PCSZ pcsz)
|
---|
40 | {
|
---|
41 | ULONG cbWritten;
|
---|
42 | DosWrite(HF_STDOUT,
|
---|
43 | (PVOID)pcsz,
|
---|
44 | strlen(pcsz),
|
---|
45 | &cbWritten);
|
---|
46 | }
|
---|
47 |
|
---|
48 | /*
|
---|
49 | *@@ fnThread:
|
---|
50 | * thread func.
|
---|
51 | */
|
---|
52 |
|
---|
53 | VOID APIENTRY fnThread(ULONG ul)
|
---|
54 | {
|
---|
55 | PTHREAD pThread = (PTHREAD)ul;
|
---|
56 | Print(pThread->pcszThreadName);
|
---|
57 | Print(" started.");
|
---|
58 | for (ul = 0;
|
---|
59 | ul < LIMIT;
|
---|
60 | ++ul)
|
---|
61 | {
|
---|
62 | Print(pThread->szMsg);
|
---|
63 | DosSleep(0);
|
---|
64 | }
|
---|
65 |
|
---|
66 | Print(pThread->pcszThreadName);
|
---|
67 | Print(" ended.");
|
---|
68 |
|
---|
69 | pThread->tid = 0;
|
---|
70 | }
|
---|
71 |
|
---|
72 | /*
|
---|
73 | *@@ StartThread:
|
---|
74 | * starts a thread suspended with the
|
---|
75 | * given priority.
|
---|
76 | *
|
---|
77 | *@@added V0.9.19 (2002-05-07) [umoeller]
|
---|
78 | */
|
---|
79 |
|
---|
80 | VOID StartThread(PTHREAD pThread)
|
---|
81 | {
|
---|
82 | DosCreateThread(&pThread->tid,
|
---|
83 | fnThread,
|
---|
84 | (ULONG)pThread,
|
---|
85 | CREATE_SUSPENDED,
|
---|
86 | 0x4000);
|
---|
87 | DosSetPriority(PRTYS_THREAD,
|
---|
88 | pThread->ulPrtyClass,
|
---|
89 | pThread->ulPrtyDelta,
|
---|
90 | pThread->tid);
|
---|
91 | }
|
---|
92 |
|
---|
93 | /*
|
---|
94 | *@@ main:
|
---|
95 | *
|
---|
96 | *@@added V0.9.19 (2002-05-07) [umoeller]
|
---|
97 | */
|
---|
98 |
|
---|
99 | int main (int argc, char *argv[])
|
---|
100 | {
|
---|
101 | THREAD tFS0 =
|
---|
102 | {
|
---|
103 | "Foreground server +0",
|
---|
104 | 4, // PRTYC_FOREGROUNDSERVER
|
---|
105 | 0, // delta
|
---|
106 | "f0",
|
---|
107 | 0 // tid
|
---|
108 | },
|
---|
109 | tTC0 =
|
---|
110 | {
|
---|
111 | "Time-critical +0",
|
---|
112 | 3, // PRTYC_TIMECRITICAL
|
---|
113 | 0, // delta
|
---|
114 | "t0",
|
---|
115 | 0 // tid
|
---|
116 | },
|
---|
117 | tTC31 =
|
---|
118 | {
|
---|
119 | "Time-critical +31",
|
---|
120 | 3, // PRTYC_TIMECRITICAL
|
---|
121 | 31, // delta
|
---|
122 | "t31",
|
---|
123 | 0 // tid
|
---|
124 | };
|
---|
125 |
|
---|
126 | // foreground server thread (class 4)
|
---|
127 | StartThread(&tFS0);
|
---|
128 | // time-critical thread (class 3)
|
---|
129 | StartThread(&tTC0);
|
---|
130 | StartThread(&tTC31);
|
---|
131 |
|
---|
132 | DosResumeThread(tFS0.tid);
|
---|
133 | DosSleep(0);
|
---|
134 | DosResumeThread(tTC0.tid);
|
---|
135 | DosSleep(0);
|
---|
136 | DosResumeThread(tTC31.tid);
|
---|
137 | DosSleep(0);
|
---|
138 |
|
---|
139 | while (tFS0.tid || tTC0.tid || tTC31.tid)
|
---|
140 | DosSleep(0);
|
---|
141 |
|
---|
142 | return 0;
|
---|
143 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.