targets/Linux/plc_Linux_main.c
author lbessard
Fri, 13 Feb 2009 13:58:54 +0100
changeset 314 ad4db7099355
parent 290 3bd617ae7a05
child 329 22e65b8e20f4
permissions -rw-r--r--
Bug with fonts on some systems fixed
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
     1
/**
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
     2
 * Linux specific code
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
     3
 **/ 
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
     4
205
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
     5
#include <stdio.h>
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
     6
#include <string.h>
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
     7
#include <time.h>
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
     8
#include <signal.h>
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
     9
#include <stdlib.h>
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    10
#include <pthread.h> 
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    11
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
    12
/* provided by POUS.C */
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
    13
extern int common_ticktime__;
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
    14
236
a32817e81f5e Now debug all ticks, not only odd ones :-)
etisserant
parents: 235
diff changeset
    15
long AtomicCompareExchange(long* atomicvar,long compared, long exchange)
205
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    16
{
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    17
    return __sync_val_compare_and_swap(atomicvar, compared, exchange);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    18
}
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    19
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    20
void PLC_GetTime(IEC_TIME *CURRENT_TIME)
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    21
{
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    22
    clock_gettime(CLOCK_REALTIME, CURRENT_TIME);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    23
}
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    24
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    25
void PLC_timer_notify(sigval_t val)
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    26
{
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    27
    PLC_GetTime(&__CURRENT_TIME);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    28
    __run();
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    29
}
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    30
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    31
timer_t PLC_timer;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    32
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    33
void PLC_SetTimer(long long next, long long period)
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    34
{
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    35
    struct itimerspec timerValues;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    36
	/*
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    37
	printf("SetTimer(%lld,%lld)\n",next, period);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    38
	*/
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    39
    memset (&timerValues, 0, sizeof (struct itimerspec));
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    40
	{
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    41
#ifdef __lldiv_t_defined
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    42
		lldiv_t nxt_div = lldiv(next, 1000000000);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    43
		lldiv_t period_div = lldiv(period, 1000000000);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    44
	    timerValues.it_value.tv_sec = nxt_div.quot;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    45
	    timerValues.it_value.tv_nsec = nxt_div.rem;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    46
	    timerValues.it_interval.tv_sec = period_div.quot;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    47
	    timerValues.it_interval.tv_nsec = period_div.rem;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    48
#else
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    49
	    timerValues.it_value.tv_sec = next / 1000000000;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    50
	    timerValues.it_value.tv_nsec = next % 1000000000;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    51
	    timerValues.it_interval.tv_sec = period / 1000000000;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    52
	    timerValues.it_interval.tv_nsec = period % 1000000000;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    53
#endif
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    54
	}	
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    55
    timer_settime (PLC_timer, 0, &timerValues, NULL);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    56
}
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    57
//
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    58
void catch_signal(int sig)
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    59
{
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    60
//  signal(SIGTERM, catch_signal);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    61
  signal(SIGINT, catch_signal);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    62
  printf("Got Signal %d\n",sig);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    63
  exit(0);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    64
}
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    65
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
    66
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
    67
static int __debug_tick;
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
    68
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
    69
static pthread_mutex_t python_wait_mutex = PTHREAD_MUTEX_INITIALIZER;
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
    70
static pthread_mutex_t python_mutex = PTHREAD_MUTEX_INITIALIZER;
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
    71
static pthread_mutex_t debug_wait_mutex = PTHREAD_MUTEX_INITIALIZER;
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
    72
static pthread_mutex_t debug_mutex = PTHREAD_MUTEX_INITIALIZER;
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
    73
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
    74
#define maxval(a,b) ((a>b)?a:b)
205
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    75
int startPLC(int argc,char **argv)
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    76
{
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    77
    struct sigevent sigev;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    78
    /* Translate PLC's microseconds to Ttick nanoseconds */
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    79
    Ttick = 1000000 * maxval(common_ticktime__,1);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    80
    
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    81
    memset (&sigev, 0, sizeof (struct sigevent));
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    82
    sigev.sigev_value.sival_int = 0;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    83
    sigev.sigev_notify = SIGEV_THREAD;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    84
    sigev.sigev_notify_attributes = NULL;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    85
    sigev.sigev_notify_function = PLC_timer_notify;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    86
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
    87
    pthread_mutex_lock(&debug_wait_mutex);
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
    88
    pthread_mutex_lock(&python_wait_mutex);
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
    89
205
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    90
    timer_create (CLOCK_REALTIME, &sigev, &PLC_timer);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    91
    if(  __init(argc,argv) == 0 ){
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    92
        PLC_SetTimer(Ttick,Ttick);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    93
        
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    94
        /* install signal handler for manual break */
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    95
//        signal(SIGTERM, catch_signal);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    96
        signal(SIGINT, catch_signal);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    97
    }else{
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    98
        return 1;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
    99
    }
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   100
    return 0;
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   101
}
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   102
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   103
int TryEnterDebugSection(void)
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   104
{
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   105
    return pthread_mutex_trylock(&debug_mutex) == 0;
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   106
}
235
a66e150f2888 Improved debug data feedback.
etisserant
parents: 227
diff changeset
   107
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   108
void LeaveDebugSection(void)
235
a66e150f2888 Improved debug data feedback.
etisserant
parents: 227
diff changeset
   109
{
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   110
    pthread_mutex_unlock(&debug_mutex);
235
a66e150f2888 Improved debug data feedback.
etisserant
parents: 227
diff changeset
   111
}
a66e150f2888 Improved debug data feedback.
etisserant
parents: 227
diff changeset
   112
205
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   113
int stopPLC()
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   114
{
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   115
    /* Stop the PLC */
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   116
    PLC_SetTimer(0,0);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   117
    timer_delete (PLC_timer);
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   118
    __cleanup();
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   119
    __debug_tick = -1;
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   120
    pthread_mutex_unlock(&debug_wait_mutex);
205
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   121
}
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   122
227
48c13b84505c - Some improovements in debug data feedback data
etisserant
parents: 205
diff changeset
   123
extern int __tick;
205
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   124
/* from plc_debugger.c */
227
48c13b84505c - Some improovements in debug data feedback data
etisserant
parents: 205
diff changeset
   125
int WaitDebugData()
205
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   126
{
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   127
    /* Wait signal from PLC thread */
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   128
    pthread_mutex_lock(&debug_wait_mutex);
227
48c13b84505c - Some improovements in debug data feedback data
etisserant
parents: 205
diff changeset
   129
    return __debug_tick;
205
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   130
}
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   131
 
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   132
/* Called by PLC thread when debug_publish finished
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   133
 * This is supposed to unlock debugger thread in WaitDebugData*/
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   134
void InitiateDebugTransfer()
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   135
{
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   136
    /* remember tick */
227
48c13b84505c - Some improovements in debug data feedback data
etisserant
parents: 205
diff changeset
   137
    __debug_tick = __tick;
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   138
    /* signal debugger thread it can read data */
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   139
    pthread_mutex_unlock(&debug_wait_mutex);
205
ee8d1f4528ef move specific target runtimes to their targets directory
greg
parents:
diff changeset
   140
}
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   141
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   142
void suspendDebug(void)
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   143
{
290
3bd617ae7a05 Local Runtime (LOCAL://) now launched "on demand"
etisserant
parents: 280
diff changeset
   144
    __DEBUG = 0;
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   145
    /* Prevent PLC to enter debug code */
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   146
    pthread_mutex_lock(&debug_mutex);
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   147
}
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   148
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   149
void resumeDebug(void)
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   150
{
290
3bd617ae7a05 Local Runtime (LOCAL://) now launched "on demand"
etisserant
parents: 280
diff changeset
   151
    __DEBUG = 1;
239
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   152
    /* Let PLC enter debug code */
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   153
    pthread_mutex_unlock(&debug_mutex);
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   154
}
112b4bc523b3 Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents: 236
diff changeset
   155
280
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   156
/* from plc_python.c */
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   157
int WaitPythonCommands(void)
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   158
{
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   159
    /* Wait signal from PLC thread */
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   160
    pthread_mutex_lock(&python_wait_mutex);
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   161
}
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   162
 
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   163
/* Called by PLC thread on each new python command*/
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   164
void UnBlockPythonCommands(void)
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   165
{
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   166
    /* signal debugger thread it can read data */
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   167
    pthread_mutex_unlock(&python_wait_mutex);
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   168
}
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   169
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   170
int TryLockPython(void)
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   171
{
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   172
    return pthread_mutex_trylock(&python_mutex) == 0;
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   173
}
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   174
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   175
void UnLockPython(void)
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   176
{
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   177
    pthread_mutex_unlock(&python_mutex);
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   178
}
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   179
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   180
void LockPython(void)
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   181
{
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   182
    pthread_mutex_lock(&python_mutex);
f2ef79f3dba0 Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents: 245
diff changeset
   183
}