mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-10 18:24:11 +01:00
PiOS.posix | more attempts to fix it on win32
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1040 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
5f6b3eb11a
commit
f82783d77e
@ -509,13 +509,13 @@ pthread_t xTaskToResume;
|
|||||||
vTaskSwitchContext();
|
vTaskSwitchContext();
|
||||||
|
|
||||||
xTaskToResume = prvGetThreadHandle( xTaskGetCurrentTaskHandle() );
|
xTaskToResume = prvGetThreadHandle( xTaskGetCurrentTaskHandle() );
|
||||||
hRequestedThread = xTaskToResume;
|
|
||||||
if ( xTaskToSuspend != xTaskToResume )
|
if ( xTaskToSuspend != xTaskToResume )
|
||||||
{
|
{
|
||||||
/* Remember and switch the critical nesting. */
|
/* Remember and switch the critical nesting. */
|
||||||
prvSetTaskCriticalNesting( xTaskToSuspend, uxCriticalNesting );
|
prvSetTaskCriticalNesting( xTaskToSuspend, uxCriticalNesting );
|
||||||
uxCriticalNesting = prvGetTaskCriticalNesting( xTaskToResume );
|
uxCriticalNesting = prvGetTaskCriticalNesting( xTaskToResume );
|
||||||
/* Switch tasks. */
|
/* Switch tasks. */
|
||||||
|
hRequestedThread = xTaskToResume;
|
||||||
prvResumeThread( xTaskToResume );
|
prvResumeThread( xTaskToResume );
|
||||||
//prvSuspendThread( xTaskToSuspend );
|
//prvSuspendThread( xTaskToSuspend );
|
||||||
if (prvGetThreadHandle(xTaskGetCurrentTaskHandle())!=xTaskToResume) {
|
if (prvGetThreadHandle(xTaskGetCurrentTaskHandle())!=xTaskToResume) {
|
||||||
@ -634,31 +634,32 @@ struct timespec timeout;
|
|||||||
vTaskSwitchContext();
|
vTaskSwitchContext();
|
||||||
#endif
|
#endif
|
||||||
xTaskToResume = prvGetThreadHandle( xTaskGetCurrentTaskHandle() );
|
xTaskToResume = prvGetThreadHandle( xTaskGetCurrentTaskHandle() );
|
||||||
hRequestedThread = xTaskToResume;
|
//hRequestedThread = xTaskToResume;
|
||||||
|
|
||||||
/* The only thread that can process this tick is the running thread. */
|
/* The only thread that can process this tick is the running thread. */
|
||||||
if ( xTaskToSuspend != xTaskToResume )
|
if ( xTaskToSuspend != xTaskToResume )
|
||||||
{
|
{
|
||||||
/* Suspend the current task. */
|
/* Suspend the current task. */
|
||||||
|
hRequestedThread = 0;
|
||||||
prvSuspendThread( xTaskToSuspend );
|
prvSuspendThread( xTaskToSuspend );
|
||||||
timeout.tv_sec=0;
|
timeout.tv_sec=0;
|
||||||
timeout.tv_nsec=10000;
|
timeout.tv_nsec=10000;
|
||||||
//if ( 0 == pthread_mutex_timedlock( &xRunningThreadMutex,&timeout ) ) {
|
while ( 0 != pthread_mutex_timedlock( &xRunningThreadMutex,&timeout ) ) {
|
||||||
if ( 0 == pthread_mutex_lock( &xRunningThreadMutex) ) {
|
prvSuspendThread( xTaskToSuspend );
|
||||||
/* Remember and switch the critical nesting. */
|
timeout.tv_sec=0;
|
||||||
prvSetTaskCriticalNesting( xTaskToSuspend, uxCriticalNesting );
|
timeout.tv_nsec=10000;
|
||||||
uxCriticalNesting = prvGetTaskCriticalNesting( xTaskToResume );
|
|
||||||
/* Resume next task. */
|
|
||||||
prvResumeThread( xTaskToResume );
|
|
||||||
if (prvGetThreadHandle(xTaskGetCurrentTaskHandle())!=xTaskToResume) {
|
|
||||||
debug_printf("\n what the fuck???? someone else did a switchcontext?!?\n");
|
|
||||||
}
|
|
||||||
(void)pthread_mutex_unlock( &xRunningThreadMutex );
|
|
||||||
} else {
|
|
||||||
debug_printf("Oh dear - tick handler could not acquire lock!\n\n");
|
|
||||||
//prvResumeThread( xTaskToSuspend );
|
|
||||||
xGeneralFuckedUpIndicator=3;
|
|
||||||
}
|
}
|
||||||
|
//if ( 0 == pthread_mutex_lock( &xRunningThreadMutex) ) {
|
||||||
|
/* Remember and switch the critical nesting. */
|
||||||
|
prvSetTaskCriticalNesting( xTaskToSuspend, uxCriticalNesting );
|
||||||
|
uxCriticalNesting = prvGetTaskCriticalNesting( xTaskToResume );
|
||||||
|
/* Resume next task. */
|
||||||
|
hRequestedThread = xTaskToResume;
|
||||||
|
prvResumeThread( xTaskToResume );
|
||||||
|
if (prvGetThreadHandle(xTaskGetCurrentTaskHandle())!=xTaskToResume) {
|
||||||
|
debug_printf("\n what the fuck???? someone else did a switchcontext?!?\n");
|
||||||
|
}
|
||||||
|
(void)pthread_mutex_unlock( &xRunningThreadMutex );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1050,6 +1051,8 @@ struct tms xTimes;
|
|||||||
*/
|
*/
|
||||||
void prvResolveFuckup( void )
|
void prvResolveFuckup( void )
|
||||||
{
|
{
|
||||||
|
struct timespec timeout;
|
||||||
|
pthread_t xTaskToResume;
|
||||||
|
|
||||||
(void)pthread_mutex_lock ( &xSuspendResumeThreadMutex);
|
(void)pthread_mutex_lock ( &xSuspendResumeThreadMutex);
|
||||||
if (hActiveThread == hRequestedThread) {
|
if (hActiveThread == hRequestedThread) {
|
||||||
@ -1057,15 +1060,27 @@ void prvResolveFuckup( void )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("\nScheduler fucked up again - lets try to fix it...\n");
|
printf("\nScheduler fucked up again - lets try to fix it...\n");
|
||||||
|
if (hRequestedThread==0) {
|
||||||
|
printf("\nno supposedly active thread - fixing\n");
|
||||||
|
xTaskToResume = prvGetThreadHandle( xTaskGetCurrentTaskHandle() );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
xTaskToResume = hRequestedThread;
|
||||||
|
}
|
||||||
printf("\nsending sig_suspend to thread that is supposed to be dead...\n");
|
printf("\nsending sig_suspend to thread that is supposed to be dead...\n");
|
||||||
prvSuspendThread(hActiveThread);
|
prvSuspendThread(hActiveThread);
|
||||||
printf("\nacquire running lock...\n");
|
printf("\nacquire running lock...\n");
|
||||||
if ( 0 == pthread_mutex_lock( &xRunningThreadMutex) ) {
|
timeout.tv_sec=0;
|
||||||
printf("\nsending sig_resume to thread that is supposed to be running...\n");
|
timeout.tv_nsec=10000;
|
||||||
prvResumeThread(hRequestedThread);
|
while ( 0 != pthread_mutex_timedlock( &xRunningThreadMutex,&timeout ) ) {
|
||||||
printf("\ngiving up mutex...\n");
|
prvSuspendThread(hActiveThread);
|
||||||
(void)pthread_mutex_unlock(&xRunningThreadMutex);
|
timeout.tv_sec=0;
|
||||||
|
timeout.tv_nsec=10000;
|
||||||
}
|
}
|
||||||
|
printf("\nsending sig_resume to thread that is supposed to be running...\n");
|
||||||
|
prvResumeThread(xTaskToResume);
|
||||||
|
printf("\ngiving up mutex...\n");
|
||||||
|
(void)pthread_mutex_unlock(&xRunningThreadMutex);
|
||||||
(void)pthread_mutex_unlock ( &xSuspendResumeThreadMutex);
|
(void)pthread_mutex_unlock ( &xSuspendResumeThreadMutex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user