mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
Ok, so its run for a bit on my windows and mac computer, although I've seen a few glitches. Also, need the version of tasks.c in peabody124 which disables interrupts while in the nanosleep command. Unfortunately for windows I have to turn of all the cpu optimization code to make it reliable for now, so it eats cycles
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1057 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
9003cd8eca
commit
083886615a
@ -76,9 +76,11 @@
|
||||
#define MAX_NUMBER_OF_TASKS ( _POSIX_THREAD_THREADS_MAX )
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
//#define COND_SIGNALING
|
||||
#define CHECK_TASK_RESUMES
|
||||
//#define RUNNING_THREAD_MUTEX
|
||||
#ifndef __CYGWIN__
|
||||
#define COND_SIGNALING
|
||||
#define CHECK_TASK_RESUMES
|
||||
#define RUNNING_THREAD_MUTEX
|
||||
#endif
|
||||
|
||||
/* Parameters to pass to the newly created pthread. */
|
||||
typedef struct XPARAMS
|
||||
@ -148,9 +150,6 @@ static void prvDeleteThread( void *xThreadId );
|
||||
void vPortYield( void );
|
||||
void vPortSystemTickHandler( int sig );
|
||||
|
||||
#define THREAD_STATE_PAUSED 0
|
||||
#define THREAD_STATE_PAUSE 1
|
||||
|
||||
#define THREAD_PAUSE_CREATED 0
|
||||
#define THREAD_PAUSE_YIELD 1
|
||||
#define THREAD_PAUSE_INTERRUPT 2
|
||||
@ -285,20 +284,22 @@ xParams *pxThisThreadParams = pvPortMalloc( sizeof( xParams ) );
|
||||
|
||||
debug_printf( "Got index for new task %i\r\n", lIndexOfLastAddedTask );
|
||||
|
||||
#ifdef COND_SIGNALING
|
||||
/* Create a condition signal for this thread */
|
||||
pthread_condattr_t condAttr;
|
||||
assert( 0 == pthread_condattr_init( &condAttr ) );
|
||||
// pthread_condattr_t condAttr;
|
||||
// assert( 0 == pthread_condattr_init( &condAttr ) );
|
||||
pxThreads[ lIndexOfLastAddedTask ].hCond = ( pthread_cond_t *) malloc( sizeof( pthread_cond_t ) );
|
||||
assert( 0 == pthread_cond_init( pxThreads[ lIndexOfLastAddedTask ].hCond , &condAttr ) );
|
||||
assert( 0 == pthread_cond_init( pxThreads[ lIndexOfLastAddedTask ].hCond , NULL ) ); //&condAttr ) );
|
||||
debug_printf("Cond: %li\r\n", *( (long int *) &pxThreads[ lIndexOfLastAddedTask ].hCond) );
|
||||
|
||||
/* Create a condition mutex for this thread */
|
||||
pthread_mutexattr_t mutexAttr;
|
||||
assert( 0 == pthread_mutexattr_init( &mutexAttr ) );
|
||||
assert( 0 == pthread_mutexattr_settype( &mutexAttr, PTHREAD_MUTEX_ERRORCHECK ) );
|
||||
// pthread_mutexattr_t mutexAttr;
|
||||
// assert( 0 == pthread_mutexattr_init( &mutexAttr ) );
|
||||
// assert( 0 == pthread_mutexattr_settype( &mutexAttr, PTHREAD_MUTEX_ERRORCHECK ) );
|
||||
pxThreads[ lIndexOfLastAddedTask ].hMutex = ( pthread_mutex_t *) malloc( sizeof( pthread_mutex_t ) );
|
||||
assert( 0 == pthread_mutex_init( pxThreads[ lIndexOfLastAddedTask ].hMutex, &mutexAttr ) );
|
||||
assert( 0 == pthread_mutex_init( pxThreads[ lIndexOfLastAddedTask ].hMutex, NULL ) ); //&mutexAttr ) );
|
||||
debug_printf("Mutex: %li\r\n", *( (long int *) &pxThreads[ lIndexOfLastAddedTask ].hMutex) );
|
||||
#endif
|
||||
|
||||
/* Create a thread and store it's handle number */
|
||||
xSentinel = 0;
|
||||
|
@ -1830,10 +1830,17 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
|
||||
// call nanosleep for smalles sleep time possible
|
||||
// (depending on kernel settings - around 100 microseconds)
|
||||
// decreases idle thread CPU load from 100 to practically 0
|
||||
#ifndef __CYGWIN__
|
||||
sigset_t xSignals;
|
||||
sigfillset( &xSignals );
|
||||
pthread_sigmask( SIG_SETMASK, &xSignals, NULL );
|
||||
struct timespec x;
|
||||
x.tv_sec=0;
|
||||
x.tv_nsec=10;
|
||||
// nanosleep(&x,NULL);
|
||||
x.tv_nsec=10000;
|
||||
nanosleep(&x,NULL);
|
||||
sigemptyset( &xSignals );
|
||||
pthread_sigmask( SIG_SETMASK, &xSignals, NULL );
|
||||
#endif
|
||||
}
|
||||
} /*lint !e715 pvParameters is not accessed but all task functions require the same prototype. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user