Example #1
0
externC void
cyg_start( void )
{
    int i;
    
    diag_init();

    diag_write_string("Philosophers\n");
    diag_write_string("Started\n");

    // Zero last element in state so it acts like
    // a string.
    pstate[PHILOSOPHERS] = 0;

#if 1
    for( i = 0; i < PHILOSOPHERS; i++ )
    {
        change_state(i,'T');            // starting state

        cyg_thread_create(4, Philosopher, (cyg_addrword_t)i, "philosopher",
            (void *)(&thread_stack[i]), STACKSIZE,
            &thread_handle[i], &thread[i]);

        // resume it
        cyg_thread_resume(thread_handle[i]);

        // and make the matching chopstick present
        cyg_semaphore_init( &chopstick[i], 1);
    }
#endif
    
    // Get the world going
    cyg_scheduler_start();

}
Example #2
0
void hal_diag_init(void)
{
#if defined(CYGSEM_HAL_ROM_MONITOR) && !defined(CYG_KERNEL_DIAG_SERIAL)
  // It's handy to have the LCD initialized at reset when using it
  // for debugging output.
  // The serial port likely doesn't work yet.  Let's wait.
  diag_write_string ("eCos ROM   " __TIME__ "\n");
  diag_write_string (__DATE__ "\n");
#endif

#if defined(CYG_KERNEL_DIAG_SERIAL)
  cyg_hal_plf_comms_init();
#endif
}
Example #3
0
//--------------------------------------------------------------------------
// do_echo --
//
static void
do_echo (int argc, char *argv[])
{
    bool newline = true;
    if (argc > 1) {
        int i = 1;
        if (strncmp (&argv[i][0], "-n", 2) == 0) {
            newline = false;
            i++;
        }
        for (; i < argc; i++) {
            diag_write_string (&argv[i][0]);
            if ((argc - i) > 1)
                diag_write_char (' ');
        }
    }
    if (newline)
        diag_write_char ('\n');
    return;
}
Example #4
0
void change_state(int id, char newstate)
{
    cyg_mutex_lock(&state_mutex);

#ifdef CYG_HAL_MN10300_MN103002
    if( pstate[id] == 'E' ) eaters--;
    if( newstate == 'E' ) eaters++;
//    led(eaters);
#endif
    
    pstate[id] = newstate;

    diag_write_string(pstate);
#if 0
    diag_write_char(' ');
    diag_write_dec(Cyg_Scheduler::get_thread_switches());
#endif    
    diag_write_char('\n');

    cyg_mutex_unlock(&state_mutex);
    
}