thread.inc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. {
  2. This file is part of the Free Pascal Run time library.
  3. Copyright (c) 2000 by the Free Pascal development team
  4. OS independent thread functions/overloads
  5. See the File COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. Var
  12. CurrentTM : TThreadManager;
  13. {$ifndef THREADVAR_RELOCATED_ALREADY_DEFINED}
  14. fpc_threadvar_relocate_proc : TRelocateThreadVarHandler; public name 'FPC_THREADVAR_RELOCATE';
  15. {$endif THREADVAR_RELOCATED_ALREADY_DEFINED}
  16. {$ifndef HAS_GETCPUCOUNT}
  17. function GetCPUCount: LongWord;
  18. begin
  19. Result := 1;
  20. end;
  21. {$endif}
  22. {*****************************************************************************
  23. Threadvar initialization
  24. *****************************************************************************}
  25. procedure InitThread(stklen:SizeUInt);
  26. begin
  27. {$ifndef FPUNONE}
  28. SysResetFPU;
  29. SysInitFPU;
  30. {$endif}
  31. {$ifndef HAS_MEMORYMANAGER}
  32. {$ifndef FPC_NO_DEFAULT_HEAP}
  33. { initialize this thread's heap }
  34. InitHeapThread;
  35. {$endif ndef FPC_NO_DEFAULT_HEAP}
  36. {$else HAS_MEMORYMANAGER}
  37. if MemoryManager.InitThread <> nil then
  38. MemoryManager.InitThread();
  39. {$endif HAS_MEMORYMANAGER}
  40. {$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
  41. if assigned(widestringmanager.ThreadInitProc) then
  42. widestringmanager.ThreadInitProc;
  43. {$endif FPC_HAS_FEATURE_WIDESTRINGS}
  44. {$ifdef FPC_HAS_FEATURE_EXCEPTIONS}
  45. { ExceptAddrStack and ExceptObjectStack are threadvars }
  46. { so every thread has its on exception handling capabilities }
  47. SysInitExceptions;
  48. {$endif FPC_HAS_FEATURE_EXCEPTIONS}
  49. {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
  50. {$ifndef EMBEDDED}
  51. { Open all stdio fds again }
  52. SysInitStdio;
  53. InOutRes:=0;
  54. // ErrNo:=0;
  55. {$endif EMBEDDED}
  56. {$endif FPC_HAS_FEATURE_CONSOLEIO}
  57. {$ifdef FPC_HAS_FEATURE_STACKCHECK}
  58. { Stack checking }
  59. StackLength:= CheckInitialStkLen(stkLen);
  60. StackBottom:=Sptr - StackLength;
  61. {$endif FPC_HAS_FEATURE_STACKCHECK}
  62. ThreadID := CurrentTM.GetCurrentThreadID();
  63. end;
  64. procedure DoneThread;
  65. begin
  66. {$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
  67. if assigned(widestringmanager.ThreadFiniProc) then
  68. widestringmanager.ThreadFiniProc;
  69. {$endif FPC_HAS_FEATURE_WIDESTRINGS}
  70. {$ifndef HAS_MEMORYMANAGER}
  71. {$ifndef FPC_NO_DEFAULT_HEAP}
  72. FinalizeHeap;
  73. {$endif ndef FPC_NO_DEFAULT_HEAP}
  74. {$endif HAS_MEMORYMANAGER}
  75. if MemoryManager.DoneThread <> nil then
  76. MemoryManager.DoneThread();
  77. {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
  78. { Open all stdio fds again }
  79. SysFlushStdio;
  80. {$endif FPC_HAS_FEATURE_CONSOLEIO}
  81. { Support platforms where threadvar memory is managed outside of the RTL:
  82. reset ThreadID and allow ReleaseThreadVars to be unassigned }
  83. ThreadID := TThreadID(0);
  84. if assigned(CurrentTM.ReleaseThreadVars) then
  85. CurrentTM.ReleaseThreadVars;
  86. end;
  87. {*****************************************************************************
  88. Overloaded functions
  89. *****************************************************************************}
  90. function BeginThread(ThreadFunction : tthreadfunc) : TThreadID;
  91. var
  92. dummy : TThreadID;
  93. begin
  94. BeginThread:=BeginThread(nil,DefaultStackSize,ThreadFunction,nil,0,dummy);
  95. end;
  96. function BeginThread(ThreadFunction : tthreadfunc;p : pointer) : TThreadID;
  97. var
  98. dummy : TThreadID;
  99. begin
  100. BeginThread:=BeginThread(nil,DefaultStackSize,ThreadFunction,p,0,dummy);
  101. end;
  102. function BeginThread(ThreadFunction : tthreadfunc;p : pointer;var ThreadId : TThreadID) : TThreadID;
  103. begin
  104. BeginThread:=BeginThread(nil,DefaultStackSize,ThreadFunction,p,0,ThreadId);
  105. end;
  106. function BeginThread(ThreadFunction : tthreadfunc;p : pointer;
  107. var ThreadId : TThreadID; const stacksize: SizeUInt) : TThreadID;
  108. begin
  109. BeginThread:=BeginThread(nil,stacksize,ThreadFunction,p,0,ThreadId);
  110. end;
  111. procedure EndThread;
  112. begin
  113. EndThread(0);
  114. end;
  115. function BeginThread(sa : Pointer;stacksize : SizeUInt; ThreadFunction : tthreadfunc;p : pointer;creationFlags : dword; var ThreadId : TThreadID) : TThreadID;
  116. begin
  117. Result:=CurrentTM.BeginThread(sa,stacksize,threadfunction,P,creationflags,ThreadID);
  118. end;
  119. procedure FlushThread;
  120. begin
  121. {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
  122. SysFlushStdio;
  123. {$endif FPC_HAS_FEATURE_CONSOLEIO}
  124. end;
  125. procedure EndThread(ExitCode : DWord);
  126. begin
  127. CurrentTM.EndThread(ExitCode);
  128. end;
  129. function SuspendThread (threadHandle : TThreadID) : dword;
  130. begin
  131. Result:=CurrentTM.SuspendThread(ThreadHandle);
  132. end;
  133. function ResumeThread (threadHandle : TThreadID) : dword;
  134. begin
  135. Result:=CurrentTM.ResumeThread(ThreadHandle);
  136. end;
  137. function CloseThread (threadHandle : TThreadID):dword;
  138. begin
  139. result:=CurrentTM.CloseThread(ThreadHandle);
  140. end;
  141. procedure ThreadSwitch;
  142. begin
  143. CurrentTM.ThreadSwitch;
  144. end;
  145. function KillThread (threadHandle : TThreadID) : dword;
  146. begin
  147. Result:=CurrentTM.KillThread(ThreadHandle);
  148. end;
  149. function WaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword;
  150. begin
  151. Result:=CurrentTM.WaitForThreadTerminate(ThreadHandle,TimeOutMS);
  152. end;
  153. function ThreadSetPriority (threadHandle : TThreadID; Prio: longint): boolean;
  154. begin
  155. Result:=CurrentTM.ThreadSetPriority(ThreadHandle,Prio);
  156. end;
  157. function ThreadGetPriority (threadHandle : TThreadID): longint;
  158. begin
  159. Result:=CurrentTM.ThreadGetPriority(ThreadHandle);
  160. end;
  161. function GetCurrentThreadId : TThreadID;
  162. begin
  163. Result:=CurrentTM.GetCurrentThreadID();
  164. end;
  165. procedure SetThreadDebugName(threadHandle: TThreadID; const ThreadName: AnsiString);
  166. begin
  167. CurrentTM.SetThreadDebugNameA(threadHandle, ThreadName);
  168. end;
  169. {$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
  170. procedure SetThreadDebugName(threadHandle: TThreadID; const ThreadName: UnicodeString);
  171. begin
  172. CurrentTM.SetThreadDebugNameU(threadHandle, ThreadName);
  173. end;
  174. {$endif FPC_HAS_FEATURE_UNICODESTRINGS}
  175. procedure InitCriticalSection(var cs : TRTLCriticalSection);
  176. begin
  177. CurrentTM.InitCriticalSection(cs);
  178. end;
  179. procedure DoneCriticalSection(var cs : TRTLCriticalSection);
  180. begin
  181. CurrentTM.DoneCriticalSection(cs);
  182. end;
  183. procedure EnterCriticalSection(var cs : TRTLCriticalSection);
  184. begin
  185. CurrentTM.EnterCriticalSection(cs);
  186. end;
  187. function TryEnterCriticalSection(var cs : TRTLCriticalSection):longint;
  188. begin
  189. result:=CurrentTM.TryEnterCriticalSection(cs);
  190. end;
  191. procedure LeaveCriticalSection(var cs : TRTLCriticalSection);
  192. begin
  193. CurrentTM.LeaveCriticalSection(cs);
  194. end;
  195. Function GetThreadManager(Var TM : TThreadManager) : Boolean;
  196. begin
  197. TM:=CurrentTM;
  198. Result:=True;
  199. end;
  200. Function SetThreadManager(Const NewTM : TThreadManager; Var OldTM : TThreadManager) : Boolean;
  201. begin
  202. GetThreadManager(OldTM);
  203. Result:=SetThreadManager(NewTM);
  204. end;
  205. Function SetThreadManager(Const NewTM : TThreadManager) : Boolean;
  206. begin
  207. Result:=True;
  208. If Assigned(CurrentTM.DoneManager) then
  209. Result:=CurrentTM.DoneManager();
  210. If Result then
  211. begin
  212. CurrentTM:=NewTM;
  213. If Assigned(CurrentTM.InitManager) then
  214. Result:=CurrentTM.InitManager();
  215. end;
  216. end;
  217. function BasicEventCreate(EventAttributes : Pointer; AManualReset,InitialState : Boolean;const Name : ansistring):pEventState;
  218. begin
  219. result:=currenttm.BasicEventCreate(EventAttributes,AManualReset,InitialState, Name);
  220. end;
  221. procedure BasicEventDestroy(state:peventstate);
  222. begin
  223. currenttm.BasicEventDestroy(state);
  224. end;
  225. procedure BasicEventResetEvent(state:peventstate);
  226. begin
  227. currenttm.BasicEventResetEvent(state);
  228. end;
  229. procedure BasicEventSetEvent(state:peventstate);
  230. begin
  231. currenttm.BasicEventSetEvent(state);
  232. end;
  233. function BasicEventWaitFor(Timeout : Cardinal;state:peventstate) : longint;
  234. begin
  235. result:=currenttm.BasicEventWaitFor(Timeout,state);
  236. end;
  237. function RTLEventCreate :PRTLEvent;
  238. begin
  239. result:=currenttm.RTLEventCreate();
  240. end;
  241. procedure RTLeventDestroy(state:pRTLEvent);
  242. begin
  243. currenttm.RTLEventDestroy(state);
  244. end;
  245. procedure RTLeventSetEvent(state:pRTLEvent);
  246. begin
  247. currenttm.RTLEventSetEvent(state);
  248. end;
  249. procedure RTLeventResetEvent(state:pRTLEvent);
  250. begin
  251. currenttm.RTLEventResetEvent(state);
  252. end;
  253. procedure RTLeventWaitFor(state:pRTLEvent);
  254. begin
  255. currenttm.RTLEventWaitFor(state);
  256. end;
  257. procedure RTLeventWaitFor(state:pRTLEvent;timeout : longint);
  258. begin
  259. currenttm.RTLEventWaitForTimeout(state,timeout);
  260. end;
  261. { ---------------------------------------------------------------------
  262. lazy thread initialization support
  263. ---------------------------------------------------------------------}
  264. var
  265. LazyInitThreadingProcs : array of TProcedure = nil;
  266. procedure RegisterLazyInitThreadingProc(const proc: TProcedure);
  267. begin
  268. if IsMultiThread then
  269. begin
  270. { multithreading is already enabled - execute directly }
  271. proc();
  272. end
  273. else
  274. begin
  275. SetLength(LazyInitThreadingProcs,Length(LazyInitThreadingProcs)+1);
  276. LazyInitThreadingProcs[high(LazyInitThreadingProcs)]:=proc;
  277. end;
  278. end;
  279. procedure LazyInitThreading;
  280. var
  281. i: Integer;
  282. begin
  283. for i:=0 to high(LazyInitThreadingProcs) do
  284. LazyInitThreadingProcs[i]();
  285. end;
  286. { ---------------------------------------------------------------------
  287. ThreadManager which gives run-time error. Use if no thread support.
  288. ---------------------------------------------------------------------}
  289. {$ifndef DISABLE_NO_THREAD_MANAGER}
  290. { resourcestrings are not supported by the system unit,
  291. they are in the objpas unit and not available for fpc/tp modes }
  292. const
  293. SNoThreads = 'This binary has no thread support compiled in.';
  294. SRecompileWithThreads = 'Recompile the application with a thread-driver in the program uses clause before other units using thread.';
  295. Procedure NoThreadError;
  296. begin
  297. {$ifndef EMBEDDED}
  298. {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
  299. If IsConsole then
  300. begin
  301. Writeln(StdErr,SNoThreads);
  302. Writeln(StdErr,SRecompileWithThreads);
  303. end;
  304. {$endif FPC_HAS_FEATURE_CONSOLEIO}
  305. {$endif EMBEDDED}
  306. RunError(232)
  307. end;
  308. function NoBeginThread(sa : Pointer;stacksize : PtrUInt;
  309. ThreadFunction : tthreadfunc;p : pointer;
  310. creationFlags : dword; var ThreadId : TThreadID) : TThreadID;
  311. begin
  312. NoThreadError;
  313. result:=tthreadid(-1);
  314. end;
  315. procedure NoEndThread(ExitCode : DWord);
  316. begin
  317. NoThreadError;
  318. end;
  319. function NoThreadHandler (threadHandle : TThreadID) : dword;
  320. begin
  321. NoThreadError;
  322. result:=dword(-1);
  323. end;
  324. function NoWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword; {0=no timeout}
  325. begin
  326. NoThreadError;
  327. result:=dword(-1);
  328. end;
  329. function NoThreadSetPriority (threadHandle : TThreadID; Prio: longint): boolean; {-15..+15, 0=normal}
  330. begin
  331. NoThreadError;
  332. result:=false;
  333. end;
  334. function NoThreadGetPriority (threadHandle : TThreadID): longint;
  335. begin
  336. NoThreadError;
  337. result:=-1;
  338. end;
  339. function NoGetCurrentThreadId : TThreadID;
  340. begin
  341. if IsMultiThread then
  342. NoThreadError
  343. else
  344. ThreadingAlreadyUsed:=true;
  345. result:=TThreadID(1);
  346. end;
  347. procedure NoSetThreadDebugNameA(threadHandle: TThreadID; const ThreadName: AnsiString);
  348. begin
  349. NoThreadError;
  350. end;
  351. {$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
  352. procedure NoSetThreadDebugNameU(threadHandle: TThreadID; const ThreadName: UnicodeString);
  353. begin
  354. NoThreadError;
  355. end;
  356. {$endif FPC_HAS_FEATURE_UNICODESTRINGS}
  357. procedure NoCriticalSection(var CS);
  358. begin
  359. if IsMultiThread then
  360. NoThreadError
  361. else
  362. ThreadingAlreadyUsed:=true;
  363. end;
  364. function NoTryEnterCriticalSection(var CS):longint;
  365. begin
  366. if IsMultiThread then
  367. NoThreadError
  368. else
  369. ThreadingAlreadyUsed:=true;
  370. Result:=-1;
  371. end;
  372. procedure NoInitThreadvar(var offset : {$ifdef cpu16}word{$else}dword{$endif};size : dword);
  373. begin
  374. NoThreadError;
  375. end;
  376. function NoRelocateThreadvar(offset : {$ifdef cpu16}word{$else}dword{$endif}) : pointer;
  377. begin
  378. NoThreadError;
  379. result:=nil;
  380. end;
  381. function NoBasicEventCreate(EventAttributes : Pointer; AManualReset,InitialState : Boolean;const Name : ansistring):pEventState;
  382. begin
  383. if IsMultiThread then
  384. NoThreadError
  385. else
  386. ThreadingAlreadyUsed:=true;
  387. result:=nil;
  388. end;
  389. procedure NoBasicEvent(state:peventstate);
  390. begin
  391. if IsMultiThread then
  392. NoThreadError
  393. else
  394. ThreadingAlreadyUsed:=true;
  395. end;
  396. function NoBasicEventWaitFor(Timeout : Cardinal;state:peventstate) : longint;
  397. begin
  398. if IsMultiThread then
  399. NoThreadError
  400. else
  401. ThreadingAlreadyUsed:=true;
  402. result:=-1;
  403. end;
  404. function NoRTLEventCreate :PRTLEvent;
  405. begin
  406. if IsMultiThread then
  407. NoThreadError
  408. else
  409. ThreadingAlreadyUsed:=true;
  410. result:=nil;
  411. end;
  412. procedure NoRTLEvent(state:pRTLEvent);
  413. begin
  414. if IsMultiThread then
  415. NoThreadError
  416. else
  417. ThreadingAlreadyUsed:=true
  418. end;
  419. procedure NoRTLEventWaitForTimeout(state:pRTLEvent;timeout : longint);
  420. begin
  421. if IsMultiThread then
  422. NoThreadError
  423. else
  424. ThreadingAlreadyUsed:=true;
  425. end;
  426. const
  427. NoThreadManager : TThreadManager = (
  428. InitManager : Nil;
  429. DoneManager : Nil;
  430. {$ifdef EMBEDDED}
  431. { while this is pretty hacky, it reduces the size of typical embedded programs
  432. and works fine on arm and avr }
  433. BeginThread : @NoBeginThread;
  434. EndThread : TEndThreadHandler(@NoThreadError);
  435. SuspendThread : TThreadHandler(@NoThreadError);
  436. ResumeThread : TThreadHandler(@NoThreadError);
  437. KillThread : TThreadHandler(@NoThreadError);
  438. CloseThread : TThreadHandler(@NoThreadError);
  439. ThreadSwitch : TThreadSwitchHandler(@NoThreadError);
  440. WaitForThreadTerminate : TWaitForThreadTerminateHandler(@NoThreadError);
  441. ThreadSetPriority : TThreadSetPriorityHandler(@NoThreadError);
  442. ThreadGetPriority : TThreadGetPriorityHandler(@NoThreadError);
  443. GetCurrentThreadId : @NoGetCurrentThreadId;
  444. SetThreadDebugNameA : TThreadSetThreadDebugNameHandlerA(@NoThreadError);
  445. {$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
  446. SetThreadDebugNameU : TThreadSetThreadDebugNameHandlerU(@NoThreadError);
  447. {$endif FPC_HAS_FEATURE_UNICODESTRINGS}
  448. InitCriticalSection : TCriticalSectionHandler(@NoThreadError);
  449. DoneCriticalSection : TCriticalSectionHandler(@NoThreadError);
  450. EnterCriticalSection : TCriticalSectionHandler(@NoThreadError);
  451. TryEnterCriticalSection: TCriticalSectionHandlerTryEnter(@NoThreadError);
  452. LeaveCriticalSection : TCriticalSectionHandler(@NoThreadError);
  453. InitThreadVar : TInitThreadVarHandler(@NoThreadError);
  454. RelocateThreadVar : TRelocateThreadVarHandler(@NoThreadError);
  455. AllocateThreadVars : @NoThreadError;
  456. ReleaseThreadVars : @NoThreadError;
  457. BasicEventCreate : TBasicEventCreateHandler(@NoThreadError);
  458. BasicEventdestroy : TBasicEventHandler(@NoThreadError);
  459. BasicEventResetEvent : TBasicEventHandler(@NoThreadError);
  460. BasicEventSetEvent : TBasicEventHandler(@NoThreadError);
  461. BasicEventWaitFor : TBasicEventWaitForHandler(@NoThreadError);
  462. RTLEventCreate : TRTLCreateEventHandler(@NoThreadError);
  463. RTLEventdestroy : TRTLEventHandler(@NoThreadError);
  464. RTLEventSetEvent : TRTLEventHandler(@NoThreadError);
  465. RTLEventResetEvent : TRTLEventHandler(@NoThreadError);
  466. RTLEventWaitFor : TRTLEventHandler(@NoThreadError);
  467. RTLEventwaitfortimeout : TRTLEventHandlerTimeout(@NoThreadError);
  468. {$else EMBEDDED}
  469. BeginThread : @NoBeginThread;
  470. EndThread : @NoEndThread;
  471. SuspendThread : @NoThreadHandler;
  472. ResumeThread : @NoThreadHandler;
  473. KillThread : @NoThreadHandler;
  474. CloseThread : @NoThreadHandler;
  475. ThreadSwitch : @NoThreadError;
  476. WaitForThreadTerminate : @NoWaitForThreadTerminate;
  477. ThreadSetPriority : @NoThreadSetPriority;
  478. ThreadGetPriority : @NoThreadGetPriority;
  479. GetCurrentThreadId : @NoGetCurrentThreadId;
  480. SetThreadDebugNameA : @NoSetThreadDebugNameA;
  481. {$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
  482. SetThreadDebugNameU : @NoSetThreadDebugNameU;
  483. {$endif FPC_HAS_FEATURE_UNICODESTRINGS}
  484. InitCriticalSection : @NoCriticalSection;
  485. DoneCriticalSection : @NoCriticalSection;
  486. EnterCriticalSection : @NoCriticalSection;
  487. TryEnterCriticalSection: @NoTryEnterCriticalSection;
  488. LeaveCriticalSection : @NoCriticalSection;
  489. InitThreadVar : @NoInitThreadVar;
  490. RelocateThreadVar : @NoRelocateThreadVar;
  491. AllocateThreadVars : @NoThreadError;
  492. ReleaseThreadVars : @NoThreadError;
  493. BasicEventCreate : @NoBasicEventCreate;
  494. BasicEventDestroy : @NoBasicEvent;
  495. BasicEventResetEvent : @NoBasicEvent;
  496. BasicEventSetEvent : @NoBasicEvent;
  497. BasicEventWaitFor : @NoBasiceventWaitFor;
  498. RTLEventCreate : @NoRTLEventCreate;
  499. RTLEventDestroy : @NoRTLevent;
  500. RTLEventSetEvent : @NoRTLevent;
  501. RTLEventResetEvent : @NoRTLEvent;
  502. RTLEventWaitFor : @NoRTLEvent;
  503. RTLEventWaitforTimeout : @NoRTLEventWaitForTimeout;
  504. {$endif EMBEDDED}
  505. );
  506. Procedure SetNoThreadManager;
  507. begin
  508. SetThreadManager(NoThreadManager);
  509. end;
  510. Procedure InitSystemThreads; public name '_FPC_InitSystemThreads';
  511. begin
  512. { This should be changed to a real value during
  513. thread driver initialization if appropriate. }
  514. ThreadID := TThreadID(1);
  515. SetNoThreadManager;
  516. end;
  517. {$endif DISABLE_NO_THREAD_MANAGER}