| 1422 | } |
| 1423 | |
| 1424 | static void cmd_sem_unlock( TARGET * t ) |
| 1425 | { |
| 1426 | CMD * cmd = ( CMD * )t->cmds; |
| 1427 | TARGETS * iter; |
| 1428 | /* Release the semaphores. */ |
| 1429 | for ( iter = cmd->unlock; iter; iter = iter->next ) |
| 1430 | { |
| 1431 | if ( DEBUG_EXECCMD ) |
| 1432 | printf( "SEM: %s is now free\n", object_str( |
| 1433 | iter->target->name ) ); |
| 1434 | --iter->target->asynccnt; |
| 1435 | assert( iter->target->asynccnt <= 0 ); |
| 1436 | } |
| 1437 | for ( iter = cmd->unlock; iter; iter = iter->next ) |
| 1438 | { |
| 1439 | /* Find a waiting target that's ready */ |
| 1440 | while ( iter->target->parents ) |
| 1441 | { |
| 1442 | TARGETS * first = iter->target->parents; |
| 1443 | TARGET * t1 = first->target; |
| 1444 | |
| 1445 | /* Pop the first waiting CMD */ |
| 1446 | if ( first->next ) |
| 1447 | first->next->tail = first->tail; |
| 1448 | iter->target->parents = first->next; |
| 1449 | BJAM_FREE( first ); |
| 1450 | |
| 1451 | if ( cmd_sem_lock( t1 ) ) |
| 1452 | { |
| 1453 | push_state( &state_stack, t1, NULL, T_STATE_MAKE1C ); |
| 1454 | break; |
| 1455 | } |
| 1456 | } |
| 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | #endif |
no test coverage detected