This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Two-threads issue with priority


Hi,

My test code is as follows,
If the priority of both thread is 4, but I use main() , only thread1 will run.
If the priority of both thread is 4, but I use cyg_user_start(), thread1 and thread2 can run.
If the priority of both thread is larger than or equal 10, no matter main() or cyg_user_start, thread1 and thread2 can run.

Why?

my hardware target is E7T

Best Regards,
Peter




**********************************************************************************************************************************

char stack[2][4096];
cyg_thread thread_s[2];
cyg_handle_t simple_threadA, simple_threadB;


void thread1(cyg_addrword_t data)
{
  int count =0;
  for(;;)
  {
    if((++count % 0x20000) == 0)
    {
        count = 0;
        *(volatile int *)(0x3ff5008) ^= 0x40;
    }
  }

}

void thread2(cyg_addrword_t data)
{
  int count;
  for(;;)
  {
    if((++count % 0x20000) == 0)
    {
        count = 0;
        *(volatile int *)(0x3ff5008) ^= 0x20;
    }
  }

}

//void cyg_user_start(void)                =========>   OK
int main(void)		          =========>   No work
{
  cyg_thread_create(4,thread1, (cyg_addrword_t) 0,"Thread 1",
                   (void *) stack[0], 4096, &simple_threadA, &thread_s[0]);
  cyg_thread_create(4,thread2, (cyg_addrword_t) 0,"Thread 2",
                   (void *) stack[1], 4096, &simple_threadB, &thread_s[1]);

  cyg_thread_resume(simple_threadA);
  cyg_thread_resume(simple_threadB);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]