void  tm_preemptive_scheduling_initialize(void)
{

    /* Create thread 0 at priority 10.  */
    tm_thread_create(0, 10, tm_preemptive_thread_0_entry);

    /* Create thread 1 at priority 9.  */
    tm_thread_create(1, 9, tm_preemptive_thread_1_entry);

    /* Create thread 2 at priority 8.  */
    tm_thread_create(2, 8, tm_preemptive_thread_2_entry);

    /* Create thread 3 at priority 7.  */
    tm_thread_create(3, 7, tm_preemptive_thread_3_entry);

    /* Create thread 4 at priority 6.  */
    tm_thread_create(4, 6, tm_preemptive_thread_4_entry);

    /* Resume just thread 0.  */
    tm_thread_resume(0);

    /* Create the reporting thread. It will preempt the other 
       threads and print out the test results.  */
    tm_thread_create(5, 2, tm_preemptive_thread_report);
    tm_thread_resume(5);
}
Ejemplo n.º 2
0
void net_notify_packet_ready(struct net_dev *nd)
{
	atomic_fetch_add(&nd->rx_pending, 1);
	if(nd->callbacks->poll)
		tm_thread_resume(nd->rec_thread.thread);
	/* TODO: notify CPU to schedule this process NOW */
}
void  tm_interrupt_processing_initialize(void)
{

    /* Create thread that generates the interrupt at priority 10.  */
    tm_thread_create(0, 10, tm_interrupt_thread_0_entry);

    /* Create a semaphore that will be posted from the interrupt 
       handler.  */
    tm_semaphore_create(0);

    /* Resume just thread 0.  */
    tm_thread_resume(0);

    /* Create the reporting thread. It will preempt the other 
       threads and print out the test results.  */
    tm_thread_create(5, 2, tm_interrupt_thread_report);
    tm_thread_resume(5);
}
/* Define the first preemptive thread.  */
void  tm_preemptive_thread_0_entry(void)
{

    while(1)
    {

        /* Resume thread 1.  */
        tm_thread_resume(1);

        /* We won't get back here until threads 1, 2, 3, and 4 all execute and
           self-suspend.  */

        /* Increment this thread's counter.  */
        tm_preemptive_thread_0_counter++;
    }
}
/* Define the fourth preemptive thread.  */
void  tm_preemptive_thread_3_entry(void)
{

    while(1)
    {

        /* Resume thread 4.  */
        tm_thread_resume(4);

        /* We won't get back here until thread 4 executes and
           self-suspends.  */

        /* Increment this thread's counter.  */
        tm_preemptive_thread_3_counter++;

        /* Suspend self!  */
        tm_thread_suspend(3);
    }
}