source: trunk/FACT++/dim/src/dim_thr.c@ 15207

Last change on this file since 15207 was 14936, checked in by tbretz, 12 years ago
Changed to v20r5.
File size: 16.5 KB
Line 
1#include <signal.h>
2#define DIMLIB
3#include "dim.h"
4
5#ifndef WIN32
6
7#ifndef NOTHREADS
8#include <pthread.h>
9#include <semaphore.h>
10#ifdef solaris
11#include <synch.h>
12#endif
13#ifdef darwin
14#include <sys/types.h>
15#include <sys/stat.h>
16#endif
17
18pthread_t IO_thread = 0;
19pthread_t ALRM_thread = 0;
20pthread_t INIT_thread = 0;
21pthread_t MAIN_thread = 0;
22#ifndef darwin
23sem_t DIM_INIT_Sema;
24/*
25sem_t DIM_WAIT_Sema;
26*/
27#else
28sem_t *DIM_INIT_Semap;
29/*
30sem_t *DIM_WAIT_Semap;
31*/
32#endif
33int INIT_count = 0;
34/*
35int WAIT_count = 0;
36*/
37int DIM_THR_init_done = 0;
38
39void *dim_tcpip_thread(void *tag)
40{
41 extern int dim_tcpip_init();
42 extern void tcpip_task();
43 /*
44 int prio;
45
46 thr_getprio(thr_self(),&prio);
47 thr_setprio(thr_self(),prio+10);
48 */
49 if(tag){}
50 IO_thread = pthread_self();
51
52 dim_tcpip_init(1);
53 if(INIT_thread)
54 {
55#ifndef darwin
56 sem_post(&DIM_INIT_Sema);
57#else
58 sem_post(DIM_INIT_Semap);
59#endif
60 }
61 while(1)
62 {
63 tcpip_task();
64 /*
65#ifndef darwin
66 sem_post(&DIM_WAIT_Sema);
67#else
68 sem_post(DIM_WAIT_Semap);
69#endif
70 */
71 dim_signal_cond();
72 }
73}
74
75void *dim_dtq_thread(void *tag)
76{
77 extern int dim_dtq_init();
78 extern int dtq_task();
79 /*
80 int prio;
81
82 thr_getprio(thr_self(),&prio);
83 thr_setprio(thr_self(),prio+5);
84 */
85 if(tag){}
86 ALRM_thread = pthread_self();
87
88 dim_dtq_init(1);
89 if(INIT_thread)
90 {
91#ifndef darwin
92 sem_post(&DIM_INIT_Sema);
93#else
94 sem_post(DIM_INIT_Semap);
95#endif
96 }
97 while(1)
98 {
99 dtq_task();
100 /*
101#ifndef darwin
102 sem_post(&DIM_WAIT_Sema);
103#else
104 sem_post(DIM_WAIT_Semap);
105#endif
106 */
107 dim_signal_cond();
108 }
109}
110
111void dim_init()
112{
113 pthread_t t_id;
114 void ignore_sigpipe();
115 extern int dna_init();
116/*
117#ifdef LYNXOS
118*/
119 pthread_attr_t attr;
120/*
121#endif
122*/
123 if(!DIM_THR_init_done)
124 {
125 /*
126 int prio;
127 */
128 DIM_THR_init_done = 1;
129 dna_init();
130 /*
131 thr_getprio(thr_self(),&prio);
132 thr_setprio(thr_self(),prio+3);
133 */
134 INIT_thread = pthread_self();
135 MAIN_thread = INIT_thread;
136
137#ifndef darwin
138 sem_init(&DIM_INIT_Sema, 0, INIT_count);
139 /*
140 sem_init(&DIM_WAIT_Sema, 0, WAIT_count);
141 */
142#else
143 DIM_INIT_Semap = sem_open("/Dim_INIT_Sem", O_CREAT, S_IRUSR | S_IWUSR, INIT_count);
144 /*
145 DIM_WAIT_Semap = sem_open("/Dim_WAIT_Sem", O_CREAT, S_IRUSR | S_IWUSR, WAIT_count);
146 */
147#endif
148
149 ignore_sigpipe();
150
151#if defined (LYNXOS) && !defined (__Lynx__)
152 pthread_attr_create(&attr);
153 pthread_create(&t_id, attr, dim_dtq_thread, 0);
154#else
155/*
156 pthread_create(&t_id, NULL, dim_dtq_thread, 0);
157*/
158 pthread_attr_init(&attr);
159 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
160 pthread_create(&t_id, &attr, dim_dtq_thread, 0);
161#endif
162#ifndef darwin
163 sem_wait(&DIM_INIT_Sema);
164#else
165 sem_wait(DIM_INIT_Semap);
166#endif
167#if defined (LYNXOS) && !defined (__Lynx__)
168 pthread_create(&t_id, attr, dim_tcpip_thread, 0);
169#else
170 pthread_create(&t_id, &attr, dim_tcpip_thread, 0);
171#endif
172#ifndef darwin
173 sem_wait(&DIM_INIT_Sema);
174#else
175 sem_wait(DIM_INIT_Semap);
176#endif
177 INIT_thread = 0;
178 }
179}
180
181void dim_stop()
182{
183 void dim_tcpip_stop(), dim_dtq_stop();
184/*
185 int i;
186 int n = 0;
187
188 for( i = 0; i< Curr_N_Conns; i++ )
189 {
190 if(Net_conns[i].channel != 0)
191 n++;
192 }
193 if(n)
194 return;
195*/
196 if(IO_thread)
197 pthread_cancel(IO_thread);
198 if(ALRM_thread)
199 pthread_cancel(ALRM_thread);
200 if(IO_thread)
201 pthread_join(IO_thread,0);
202 if(ALRM_thread)
203 pthread_join(ALRM_thread,0);
204#ifndef darwin
205 sem_destroy(&DIM_INIT_Sema);
206 /*
207 sem_destroy(&DIM_WAIT_Sema);
208 */
209#else
210 sem_unlink("/Dim_INIT_Sem");
211 /*
212 sem_unlink("/Dim_WAIT_Sem");
213 */
214 sem_close(DIM_INIT_Semap);
215 /*
216 sem_close(DIM_WAIT_Semap);
217 */
218#endif
219 dim_tcpip_stop();
220 dim_dtq_stop();
221 IO_thread = 0;
222 ALRM_thread = 0;
223 DIM_THR_init_done = 0;
224}
225
226dim_long dim_start_thread(void *(*thread_ast)(void *), dim_long tag)
227{
228 pthread_t t_id;
229 pthread_attr_t attr;
230
231#if defined (LYNXOS) && !defined (__Lynx__)
232 pthread_attr_create(&attr);
233 pthread_create(&t_id, attr, (void *)thread_ast, (void *)tag);
234#else
235 pthread_attr_init(&attr);
236 pthread_create(&t_id, &attr, thread_ast, (void *)tag);
237#endif
238 return((dim_long)t_id);
239}
240
241int dim_stop_thread(dim_long t_id)
242{
243 int ret;
244 ret = pthread_cancel((pthread_t)t_id);
245 dim_print_date_time();
246 printf("dim_stop_thread: this function is obsolete, it creates memory leaks\n");
247 return ret;
248}
249
250int dim_set_scheduler_class(int pclass)
251{
252#ifdef __linux__
253 int ret, prio, p;
254 struct sched_param param;
255
256 if(pclass == 0)
257 {
258 pclass = SCHED_OTHER;
259 }
260 else if(pclass == 1)
261 {
262 pclass = SCHED_FIFO;
263 }
264 else if(pclass == 2)
265 {
266 pclass = SCHED_RR;
267 }
268 prio = sched_get_priority_min(pclass);
269 ret = pthread_getschedparam(MAIN_thread, &p, &param);
270 if( (p == SCHED_OTHER) || (pclass == SCHED_OTHER) )
271 param.sched_priority = prio;
272 ret = pthread_setschedparam(MAIN_thread, pclass, &param);
273 if(ret)
274 return 0;
275 ret = pthread_getschedparam(IO_thread, &p, &param);
276 if( (p == SCHED_OTHER) || (pclass == SCHED_OTHER) )
277 param.sched_priority = prio;
278 ret = pthread_setschedparam(IO_thread, pclass, &param);
279 if(ret)
280 return 0;
281 ret = pthread_getschedparam(ALRM_thread, &p, &param);
282 if( (p == SCHED_OTHER) || (pclass == SCHED_OTHER) )
283 param.sched_priority = prio;
284 ret = pthread_setschedparam(ALRM_thread, pclass, &param);
285 if(!ret)
286 return 1;
287#endif
288 return 0;
289}
290
291int dim_get_scheduler_class(int *pclass)
292{
293#ifdef __linux__
294 int ret;
295 struct sched_param param;
296
297 ret = pthread_getschedparam(MAIN_thread, pclass, &param);
298 if(!ret)
299 return 1;
300#endif
301 return 0;
302}
303
304int dim_set_priority(int threadId, int prio)
305{
306#ifdef __linux__
307 pthread_t id = MAIN_thread;
308 int ret;
309 int pclass;
310 struct sched_param param;
311
312 if(threadId == 1)
313 id = MAIN_thread;
314 else if(threadId == 2)
315 id = IO_thread;
316 else if(threadId == 3)
317 id = ALRM_thread;
318
319 ret = pthread_getschedparam(id, &pclass, &param);
320 param.sched_priority = prio;
321 ret = pthread_setschedparam(id, pclass, &param);
322 if(!ret)
323 return 1;
324#endif
325 return 0;
326}
327
328int dim_get_priority(int threadId, int *prio)
329{
330#ifdef __linux__
331 pthread_t id=MAIN_thread;
332 int ret;
333 int pclass;
334 struct sched_param param;
335
336 if(threadId == 1)
337 id = MAIN_thread;
338 else if(threadId == 2)
339 id = IO_thread;
340 else if(threadId == 3)
341 id = ALRM_thread;
342
343 ret = pthread_getschedparam(id, &pclass, &param);
344 *prio = param.sched_priority;
345 if(!ret)
346 return 1;
347#endif
348 return 0;
349}
350
351void ignore_sigpipe()
352{
353
354 struct sigaction sig_info;
355 sigset_t set;
356 void pipe_sig_handler();
357
358 if( sigaction(SIGPIPE, 0, &sig_info) < 0 )
359 {
360 perror( "sigaction(SIGPIPE)" );
361 exit(1);
362 }
363 if(sig_info.sa_handler)
364 {
365/*
366 printf("DIM ignore_sigpipe() - Handler already defined %08X\n", sig_info.sa_handler);
367*/
368 return;
369 }
370 sigemptyset(&set);
371 sig_info.sa_handler = pipe_sig_handler;
372 sig_info.sa_mask = set;
373#ifndef LYNXOS
374 sig_info.sa_flags = SA_RESTART;
375#else
376 sig_info.sa_flags = 0;
377#endif
378
379 if( sigaction(SIGPIPE, &sig_info, 0) < 0 )
380 {
381 perror( "sigaction(SIGPIPE)" );
382 exit(1);
383 }
384}
385
386void pipe_sig_handler( int num )
387{
388 if(num){}
389/*
390 printf( "*** pipe_sig_handler called ***\n" );
391*/
392}
393
394void dim_init_threads()
395{
396 dim_init();
397}
398
399void dim_stop_threads()
400{
401 dim_stop();
402}
403
404int dim_wait(void)
405{
406 pthread_t id;
407
408 id = pthread_self();
409
410 if((id == ALRM_thread) || (id == IO_thread))
411 {
412 return(-1);
413 }
414 /*
415#ifndef darwin
416 sem_wait(&DIM_WAIT_Sema);
417#else
418 sem_wait(DIM_WAIT_Semap);
419#endif
420 */
421 dim_wait_cond();
422 return(-1);
423}
424
425/*
426static void show_ast()
427{
428sigset_t oset;
429
430 sigprocmask(SIG_SETMASK,0,&oset);
431 printf("---THREAD id = %d, mask = %x %x\n",
432 pthread_self(), oset.__sigbits[1], oset.__sigbits[0]);
433}
434*/
435
436pthread_t Dim_thr_locker = 0;
437int Dim_thr_counter = 0;
438#ifdef LYNXOS
439pthread_mutex_t Global_DIM_mutex;
440pthread_mutex_t Global_cond_mutex;
441pthread_cond_t Global_cond;
442#else
443pthread_mutex_t Global_DIM_mutex = PTHREAD_MUTEX_INITIALIZER;
444pthread_mutex_t Global_cond_mutex = PTHREAD_MUTEX_INITIALIZER;
445pthread_cond_t Global_cond = PTHREAD_COND_INITIALIZER;
446#endif
447int Global_cond_counter = 0;
448int Global_cond_waiters = 0;
449
450void dim_lock()
451{
452 /*printf("Locking %d ", pthread_self());*/
453 if(Dim_thr_locker != pthread_self())
454 {
455/*
456#ifdef __linux__
457 pthread_testcancel();
458#endif
459*/
460 pthread_mutex_lock(&Global_DIM_mutex);
461 Dim_thr_locker=pthread_self();
462 /*printf(": Locked ");*/
463 }
464 /*printf("Counter = %d\n",Dim_thr_counter);*/
465 Dim_thr_counter++;
466}
467void dim_unlock()
468{
469 /*printf("Un-Locking %d ", pthread_self());*/
470 Dim_thr_counter--;
471 /*printf("Counter = %d ",Dim_thr_counter);*/
472 if(!Dim_thr_counter)
473 {
474 Dim_thr_locker=0;
475 pthread_mutex_unlock(&Global_DIM_mutex);
476 /*printf(": Un-Locked ");*/
477 }
478 /* printf("\n");*/
479}
480
481void dim_wait_cond()
482{
483 pthread_mutex_lock(&Global_cond_mutex);
484 Global_cond_waiters++;
485 if(!Global_cond_counter)
486 {
487 pthread_cond_wait(&Global_cond, &Global_cond_mutex);
488 }
489 Global_cond_waiters--;
490 if(!Global_cond_waiters)
491 Global_cond_counter--;
492 pthread_mutex_unlock(&Global_cond_mutex);
493}
494
495void dim_signal_cond()
496{
497 pthread_mutex_lock(&Global_cond_mutex);
498 if(!Global_cond_waiters)
499 {
500 Global_cond_counter = 1;
501 }
502 else
503 {
504 Global_cond_counter++;
505 pthread_cond_broadcast(&Global_cond);
506 }
507 pthread_mutex_unlock(&Global_cond_mutex);
508}
509
510#else
511
512void dim_init()
513{
514}
515
516void dim_init_threads()
517{
518}
519
520void dim_stop_threads()
521{
522}
523
524void dim_stop()
525{
526}
527
528int dim_wait()
529{
530 pause();
531 return(-1);
532}
533
534dim_long dim_start_thread(void (*thread_ast)(), dim_long tag)
535
536{
537 if(thread_ast){}
538 if(tag){}
539 printf("dim_start_thread: not available\n");
540 return (dim_long)0;
541}
542
543int dim_stop_thread(dim_long t_id)
544{
545 if(t_id){}
546 printf("dim_stop_thread: not available\n");
547 return 0;
548}
549#endif
550
551#else
552#include <windows.h>
553
554DWORD IO_thread = 0;
555DWORD ALRM_thread = 0;
556DWORD MAIN_thread = 0;
557HANDLE hIO_thread;
558HANDLE hALRM_thread;
559HANDLE hMAIN_thread;
560DllExp HANDLE Global_DIM_event_auto = 0;
561DllExp HANDLE Global_DIM_mutex = 0;
562DllExp HANDLE Global_DIM_event_manual = 0;
563void dim_tcpip_stop(), dim_dtq_stop();
564
565typedef struct{
566 void (*thread_ast)();
567 dim_long tag;
568
569}THREAD_PARAMS;
570
571#ifndef STDCALL
572dim_long dim_start_thread(void (*thread_ast)(), dim_long tag)
573#else
574dim_long dim_start_thread(dim_long (*thread_ast)(void *), void *tag)
575#endif
576{
577DWORD threadid = 0;
578HANDLE hthread;
579
580#ifndef STDCALL
581 hthread = CreateThread(
582 NULL, /* no security attributes */
583 0, /* use default stack size */
584 (void *)thread_ast, /* thread function */
585 (void *)tag, /* argument to thread function */
586 0, /* use default creation flags */
587 &threadid); /* returns the thread identifier */
588#else
589 hthread = CreateThread(
590 NULL, /* no security attributes */
591 0, /* use default stack size */
592 thread_ast, /* thread function */
593 tag, /* argument to thread function */
594 0, /* use default creation flags */
595 &threadid); /* returns the thread identifier */
596#endif
597 return (dim_long)hthread;
598}
599
600
601int dim_stop_thread(dim_long thread_id)
602{
603 int ret;
604
605 ret = TerminateThread((HANDLE)thread_id, 0);
606 CloseHandle((HANDLE)thread_id);
607 printf("dim_stop_thread: this function is obsolete, it creates memory leaks\n");
608 return ret;
609}
610
611
612void create_io_thread()
613{
614 int tcpip_task(void *);
615
616#ifndef STDCALL
617 hIO_thread = CreateThread(
618 NULL, /* no security attributes */
619 0, /* use default stack size */
620 (void *)tcpip_task, /* thread function */
621 0, /* argument to thread function */
622 0, /* use default creation flags */
623 &IO_thread); /* returns the thread identifier */
624#else
625 hIO_thread = CreateThread(
626 NULL, /* no security attributes */
627 0, /* use default stack size */
628 tcpip_task, /* thread function */
629 0, /* argument to thread function */
630 0, /* use default creation flags */
631 &IO_thread); /* returns the thread identifier */
632#endif
633}
634
635void create_alrm_thread()
636{
637
638 int dtq_task(void *);
639
640#ifndef STDCALL
641 hALRM_thread = CreateThread(
642 NULL,
643 0,
644 (void *)dtq_task,
645 0,
646 0,
647 &ALRM_thread);
648#else
649 hALRM_thread = CreateThread(
650 NULL,
651 0,
652 dtq_task,
653 0,
654 0,
655 &ALRM_thread);
656#endif
657}
658
659void dim_init_threads()
660{
661 static int done = 0;
662
663 if(!done)
664 {
665 hMAIN_thread = GetCurrentThread();
666 done = 1;
667 }
668}
669
670void dim_stop_threads()
671{
672/*
673 int i;
674 int n = 0;
675
676 for( i = 0; i< Curr_N_Conns; i++ )
677 {
678 if(Net_conns[i].channel != 0)
679 n++;
680 }
681 if(n)
682 return;
683*/
684 if(hIO_thread)
685 TerminateThread(hIO_thread, 0);
686 if(hALRM_thread)
687 TerminateThread(hALRM_thread, 0);
688 if(Global_DIM_mutex)
689 CloseHandle(Global_DIM_mutex);
690 if(Global_DIM_event_auto)
691 CloseHandle(Global_DIM_event_auto);
692 if(Global_DIM_event_manual)
693 CloseHandle(Global_DIM_event_manual);
694 hIO_thread = 0;
695 hALRM_thread = 0;
696 Global_DIM_mutex = 0;
697 Global_DIM_event_auto = 0;
698 Global_DIM_event_manual = 0;
699 dim_tcpip_stop();
700 dim_dtq_stop();
701}
702
703void dim_stop()
704{
705 dim_stop_threads();
706}
707
708int dim_set_scheduler_class(int pclass)
709{
710 HANDLE hProc;
711 int ret;
712 DWORD p;
713
714#ifndef PXI
715 hProc = GetCurrentProcess();
716
717 if(pclass == -1)
718 p = IDLE_PRIORITY_CLASS;
719/*
720 else if(pclass == -1)
721 p = BELOW_NORMAL_PRIORITY_CLASS;
722*/
723 else if(pclass == 0)
724 p = NORMAL_PRIORITY_CLASS;
725/*
726 else if(pclass == 1)
727 p == ABOVE_NORMAL_PRIORITY_CLASS;
728*/
729 else if(pclass == 1)
730 p = HIGH_PRIORITY_CLASS;
731 else if(pclass == 2)
732 p = REALTIME_PRIORITY_CLASS;
733 ret = SetPriorityClass(hProc, p);
734 if(ret)
735 return 1;
736 ret = GetLastError();
737 printf("ret = %x %d\n",ret, ret);
738 return 0;
739#else
740 return 0;
741#endif
742}
743
744int dim_get_scheduler_class(int *pclass)
745{
746 HANDLE hProc;
747 DWORD ret;
748
749#ifndef PXI
750 hProc = GetCurrentProcess();
751
752 ret = GetPriorityClass(hProc);
753 if(ret == 0)
754 return 0;
755 if(ret == IDLE_PRIORITY_CLASS)
756 *pclass = -1;
757/*
758 else if(ret == BELOW_NORMAL_PRIORITY_CLASS)
759 *pclass = -1;
760*/
761 else if(ret == NORMAL_PRIORITY_CLASS)
762 *pclass = 0;
763/*
764 else if(ret == ABOVE_NORMAL_PRIORITY_CLASS)
765 *pclass = 1;
766*/
767 else if(ret == HIGH_PRIORITY_CLASS)
768 *pclass = 1;
769 else if(ret == REALTIME_PRIORITY_CLASS)
770 *pclass = 2;
771 return 1;
772#else
773 *pclass = 0;
774 return 0;
775#endif
776}
777
778int dim_set_priority(int threadId, int prio)
779{
780 HANDLE id;
781 int ret, p;
782
783#ifndef PXI
784 if(threadId == 1)
785 id = hMAIN_thread;
786 else if(threadId == 2)
787 id = hIO_thread;
788 else if(threadId == 3)
789 id = hALRM_thread;
790
791 if(prio == -3)
792 p = THREAD_PRIORITY_IDLE;
793 if(prio == -2)
794 p = THREAD_PRIORITY_LOWEST;
795 if(prio == -1)
796 p = THREAD_PRIORITY_BELOW_NORMAL;
797 if(prio == 0)
798 p = THREAD_PRIORITY_NORMAL;
799 if(prio == 1)
800 p = THREAD_PRIORITY_ABOVE_NORMAL;
801 if(prio == 2)
802 p = THREAD_PRIORITY_HIGHEST;
803 if(prio == 3)
804 p = THREAD_PRIORITY_TIME_CRITICAL;
805
806 ret = SetThreadPriority(id, p);
807 if(ret)
808 return 1;
809 return 0;
810#else
811 return 0;
812#endif
813}
814
815int dim_get_priority(int threadId, int *prio)
816{
817 HANDLE id;
818 int ret, p;
819
820#ifndef PXI
821 if(threadId == 1)
822 id = hMAIN_thread;
823 else if(threadId == 2)
824 id = hIO_thread;
825 else if(threadId == 3)
826 id = hALRM_thread;
827
828 ret = GetThreadPriority(id);
829 if(ret == THREAD_PRIORITY_ERROR_RETURN)
830 return 0;
831 if(ret == THREAD_PRIORITY_IDLE)
832 p = -3;
833 if(ret == THREAD_PRIORITY_LOWEST)
834 p = -2;
835 if(ret == THREAD_PRIORITY_BELOW_NORMAL)
836 p = -1;
837 if(ret == THREAD_PRIORITY_NORMAL)
838 p = 0;
839 if(ret == THREAD_PRIORITY_ABOVE_NORMAL)
840 p = 1;
841 if(ret == THREAD_PRIORITY_HIGHEST)
842 p = 2;
843 if(ret == THREAD_PRIORITY_TIME_CRITICAL)
844 p = 3;
845 *prio = p;
846 return 1;
847#else
848 *prio = 0;
849 return 0;
850#endif
851}
852
853void dim_init()
854{
855}
856
857void dim_no_threads()
858{
859}
860
861int dim_wait()
862{
863 pause();
864 return(1);
865}
866
867void dim_lock()
868{
869 if(!Global_DIM_mutex)
870 {
871 Global_DIM_mutex = CreateMutex(NULL,FALSE,NULL);
872 }
873 WaitForSingleObject(Global_DIM_mutex, INFINITE);
874}
875
876void dim_unlock()
877{
878 ReleaseMutex(Global_DIM_mutex);
879}
880
881void dim_pause()
882{
883HANDLE handles[2];
884
885 if(!Global_DIM_event_auto)
886 {
887 Global_DIM_event_auto = CreateEvent(NULL,FALSE,FALSE,NULL);
888 Global_DIM_event_manual = CreateEvent(NULL,TRUE,FALSE,NULL);
889 }
890 else
891 {
892/*
893 WaitForSingleObject(Global_DIM_event, INFINITE);
894*/
895 handles[0] = Global_DIM_event_auto;
896 handles[1] = Global_DIM_event_manual;
897 WaitForMultipleObjects(2, handles, FALSE, INFINITE);
898 }
899}
900
901void dim_wake_up()
902{
903 if(Global_DIM_event_auto)
904 {
905 SetEvent(Global_DIM_event_auto);
906 }
907 if(Global_DIM_event_manual)
908 {
909 SetEvent(Global_DIM_event_manual);
910 ResetEvent(Global_DIM_event_manual);
911 }
912}
913
914void dim_sleep(unsigned int t)
915{
916 Sleep(t*1000);
917}
918
919void dim_win_usleep(unsigned int t)
920{
921 Sleep(t/1000);
922}
923
924#endif
Note: See TracBrowser for help on using the repository browser.