AzureMXChip/MXCHIPAZ3166/core/lib/threadx/ports_smp/linux/gnu/src/tx_initialize_low_level.c
void    *_tx_linux_timer_interrupt(void *p)
{
struct timespec ts;
long timer_periodic_sec;
long timer_periodic_nsec;
int err;

    /* Calculate periodic timer. */
    timer_periodic_sec = 1 / TX_TIMER_TICKS_PER_SECOND;
    timer_periodic_nsec = 1000000000 / TX_TIMER_TICKS_PER_SECOND;
    nice(10);

    /* Wait startup semaphore. */
    tx_linux_sem_wait(&_tx_linux_timer_semaphore);

    while(1)
    {

        clock_gettime(CLOCK_REALTIME, &ts);
        ts.tv_nsec += timer_periodic_nsec;
        if (ts.tv_nsec > 1000000000)
        {
            ts.tv_nsec -= 1000000000;
            ts.tv_sec++;
        }
        do
        {
            if (sem_timedwait(&_tx_linux_timer_semaphore, &ts) == 0)
            {
                break;
            }
            err = errno;
        } while (err != ETIMEDOUT);

        /* Call ThreadX context save for interrupt preparation.  */
        _tx_thread_context_save();

        /* Call the ThreadX system timer interrupt processing.  */
        _tx_timer_interrupt();

        /* Call ThreadX context restore for interrupt completion.  */
        _tx_thread_context_restore();
    }
}
/* Define the ThreadX system timer interrupt.  Other interrupts may be simulated
   in a similar way.  */
Define the ThreadX system timer interrupt.  Other interrupts may be simulated
in a similar way.
Define the ThreadX system timer interrupt . Other interrupts may be simulated in a similar way .
void    *_tx_linux_timer_interrupt(void *p)
{
struct timespec ts;
long timer_periodic_sec;
long timer_periodic_nsec;
int err;
    timer_periodic_sec = 1 / TX_TIMER_TICKS_PER_SECOND;
    timer_periodic_nsec = 1000000000 / TX_TIMER_TICKS_PER_SECOND;
    nice(10);
    tx_linux_sem_wait(&_tx_linux_timer_semaphore);
    while(1)
    {
        clock_gettime(CLOCK_REALTIME, &ts);
        ts.tv_nsec += timer_periodic_nsec;
        if (ts.tv_nsec > 1000000000)
        {
            ts.tv_nsec -= 1000000000;
            ts.tv_sec++;
        }
        do
        {
            if (sem_timedwait(&_tx_linux_timer_semaphore, &ts) == 0)
            {
                break;
            }
            err = errno;
        } while (err != ETIMEDOUT);
        _tx_thread_context_save();
        _tx_timer_interrupt();
        _tx_thread_context_restore();
    }
}
void * _tx_linux_timer_interrupt ( void * p ) { struct timespec ts ; long timer_periodic_sec ; long timer_periodic_nsec ; int err ; timer_periodic_sec = 1 / TX_TIMER_TICKS_PER_SECOND ; timer_periodic_nsec = 1000000000 / TX_TIMER_TICKS_PER_SECOND ; nice ( 10 ) ; tx_linux_sem_wait ( & _tx_linux_timer_semaphore ) ; while ( 1 ) { clock_gettime ( CLOCK_REALTIME , & ts ) ; ts . tv_nsec += timer_periodic_nsec ; if ( ts . tv_nsec > 1000000000 ) { ts . tv_nsec -= 1000000000 ; ts . tv_sec ++ ; } do { if ( sem_timedwait ( & _tx_linux_timer_semaphore , & ts ) == 0 ) { break ; } err = errno ; } while ( err != ETIMEDOUT ) ; _tx_thread_context_save ( ) ; _tx_timer_interrupt ( ) ; _tx_thread_context_restore ( ) ; } }
Define the ThreadX system timer interrupt.
Define the ThreadX system timer interrupt .
/* Calculate periodic timer. */ /* Wait startup semaphore. */ /* Call ThreadX context save for interrupt preparation.  */ /* Call the ThreadX system timer interrupt processing.  */ /* Call ThreadX context restore for interrupt completion.  */