Ejemplo n.º 1
0
static thread_state     *AddThread( dtid_t tid, unsigned state )
{
    thread_state    **owner;
    thread_state    *thd;
    char            name[UTIL_LEN];

    owner =  &HeadThd;
    for( ;; ) {
        thd = *owner;
        if( thd == NULL ) break;
        if( tid < thd->tid ) break;
        if( tid == thd->tid ) {
            if( _IsOn( SW_THREAD_EXTRA_CHANGED ) ) {
                *owner = thd->link;
                state = thd->state & ~THD_DEAD;
                _Free( thd );
                break;
            }
            thd->state &= ~THD_DEAD;
            return( thd );
        }
        owner = &thd->link;
    }
    if( HaveRemoteRunThread() )
        RemoteRunThdName( tid, name );
    else
        RemoteThdName( tid, name );
    _Alloc( thd, sizeof( thread_state ) + strlen( name ) );
    if( thd == NULL ) return( NULL );
    thd->link = *owner;
    *owner = thd;
    strcpy( thd->name, name );
    thd->tid = tid;
    thd->state = state;
    thd->cs = 0;
    thd->eip = 0;
    thd->extra[0] = 0;
    return( thd );
}
Ejemplo n.º 2
0
static  bool    TrdGetLine( a_window *wnd, int row, int piece,
                             wnd_line_piece *line )
{
    thread_state        *thd = GetThreadRow( row );

    line->indent = Indents[piece] * WndAvgCharX( wnd );
    if( row < 0 ) {
        row += TITLE_SIZE;
        switch( row ) {
        case 0:
            switch( piece ) {
            case PIECE_ID:
                line->text = LIT_DUI( ID );
                return( true );
            case PIECE_STATE:
                line->text = LIT_DUI( State );
                return( true );
            case PIECE_NAME:
                line->text = TxtBuff;
                RemoteThdName( 0, TxtBuff ); // nyi - pui - line up in proportional font
                return( true );
            default:
                return( false );
            }
        case 1:
            if( piece != 0 )
                return( false );
            SetUnderLine( wnd, line );
            return( true );
        default:
            return( false );
        }
    } else {
        if( thd == NULL )
            return( false );
        line->tabstop = false;
        line->use_prev_attr = true;
        line->extent = WND_MAX_EXTEND;
        switch( piece ) {
        case PIECE_ID:
            line->tabstop = true;
            line->use_prev_attr = false;
            line->text = TxtBuff;
            CnvULongHex( thd->tid, TxtBuff, TXT_LEN );
            return( true );
        case PIECE_STATE:
            if( IsThdCurr( thd ) ) {
                line->text = LIT_ENG( Current );
            } else {
                switch( thd->state ) {
                case THD_THAW:
                    line->text = LIT_ENG( Runnable );
                    break;
                case THD_FREEZE:
                    line->text = LIT_ENG( Frozen );
                    break;
                case THD_WAIT:
                    line->text = LIT_ENG( Wait );
                    break;  
                case THD_SIGNAL:
                    line->text = LIT_ENG( Signal );
                    break;  
                case THD_KEYBOARD:
                    line->text = LIT_ENG( Keyboard );
                    break;  
                case THD_BLOCKED:
                    line->text = LIT_ENG( Blocked );
                    break;  
                case THD_RUN:
                    line->text = LIT_ENG( Executing );
                    break;  
                case THD_DEBUG:
                    line->text = LIT_ENG( Debug );
                    break;
                case THD_DEAD:
                    line->text = LIT_ENG( Dead );
                    break;
                }
            }
            return( true );
        case PIECE_NAME:
            line->tabstop = false;
            line->use_prev_attr = true;
            line->text = thd->name;
            return( true );
        }
    }
    return( false );
}