--- a/targets/OSX/plc_OSX_main.c Thu Nov 10 10:45:40 2022 +0800
+++ b/targets/OSX/plc_OSX_main.c Thu Nov 10 18:10:42 2022 +0800
@@ -12,7 +12,7 @@
#include <dispatch/dispatch.h>
+static dispatch_semaphore_t Run_PLC; long AtomicCompareExchange(long *atomicvar, long compared, long exchange)
@@ -46,7 +46,7 @@
static inline void PLC_timer_notify(void *arg)
PLC_GetTime(&__CURRENT_TIME);
+ dispatch_semaphore_signal(Run_PLC); void PLC_SetTimer(unsigned long long next, unsigned long long period)
@@ -87,7 +87,7 @@
void PLC_thread_proc(void *arg)
+ dispatch_semaphore_wait(Run_PLC, DISPATCH_TIME_FOREVER); @@ -100,7 +100,7 @@
- sem_init(&Run_PLC, 0, 0);
+ Run_PLC = dispatch_semaphore_create(0); pthread_create(&PLC_thread, NULL, (void *)&PLC_thread_proc, NULL);
@@ -151,10 +151,11 @@
+ dispatch_semaphore_signal(Run_PLC); pthread_join(PLC_thread, NULL);
+ dispatch_release(Run_PLC); dispatch_source_cancel(PLC_timer);
pthread_mutex_destroy(&debug_wait_mutex);