From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Garnett To: Jonathan Larmour Cc: jaiprakash@inablers.net, ecos-discuss@sources.redhat.com Subject: Re: [ECOS] Thread related queries Date: Fri, 07 Sep 2001 02:34:00 -0000 Message-id: References: <200108251135.RAA16753@inablers.net> <3B97D7A9.1E29D21A@redhat.com> X-SW-Source: 2001-09/msg00177.html Jonathan Larmour writes: > Jaiprakash wrote: > > On linux the control goes to main() once, later the threads keep > > running continuously. But in ecos the main() seems to get more > > timeslice (15 - 20 times more) than the three threads. My basic clock > > tick is 0.5 secs and timeslicing is 2 ticks. can you give me some > > inputs regarding the difference of behaviour eventhough i am using > > pthread calls. > > eCos is a real-time system (which Linux is not), which means you have to be > concerned about the thread priorities. A higher priority thread will get > all the CPU, unless it has been blocked for some reason. main()'s (eCos) > priority is set with the configuration variable > CYGNUM_POSIX_MAIN_DEFAULT_PRIORITY, and defaults to 30. > > Unfortunately, a POSIX thread has a default POSIX priority of 0, which > translates to an ECOS_PRIORITY of (CYG_THREAD_MIN_PRIORITY-priority) i.e. > 31. Not only is this less than main's, it is the same as the idle thread, > meaning it will be timeslicing with it. > > I think instead sched_priority in pthread_attr_init() should default to 1. > Nick, know any reason why not? > It is actually irrelevant, since the inherit attribute is set to PTHREAD_INHERIT_SCHED the default is for all threads to inherit the priority of their creator. Without looking at Jaiprakash's program, it is difficult to know what is actually happening. -- Nick Garnett, eCos Kernel Architect Red Hat, Cambridge, UK