From: "Jaiprakash" <jaiprakash@inablers.net>
To: ecos-discuss@sources.redhat.com
Subject: [ECOS] Thread related queries
Date: Sat, 25 Aug 2001 04:09:00 -0000 [thread overview]
Message-ID: <200108251135.RAA16753@inablers.net> (raw)
Hello,
I have the following queries regarding implementation of threading in
ecos:
1. Does ecos consider main() as a running thread or is it just an entry
point to the system.
2. What is Cyg_Idle_thread used for? its functionality is not clear.
3. I was trying to compare following piece of code on linux 6.2 and
ecos running on my board.
#include <pthread.h>
#include <signal.h>
#define NUM_THREADS 3
void *PrintThreadid(void *threadid)
{
int i;
for(;;){
printf("\nthread %d\n",threadid);
i = sleep(1);
if(i) {
printf("return value from sleep() %d", i);
}
}
}
int main()
{
pthread_t threads[NUM_THREADS];
int rc, t,i,j;
int *thread_return;
pthread_attr_t attr;
rc = pthread_attr_init(&attr);
if(rc){
printf("ERROR: return code from pthread_attr_init %d", rc);
}
printf("\n creating threads\n");
for(t=0;t < NUM_THREADS;t++){
rc = pthread_create(&threads[t], &attr, PrintThreadid, (void *)
t);
if (rc){
printf("ERROR; return code from pthread_create()%d ", rc);
}
}
printf("\n running main thread\n");
pthread_attr_destroy(&attr);
for(t=0;t < NUM_THREADS;t++){
rc = pthread_join(threads[t], (void *)&thread_return);
if(rc){
printf("ERROR: return code from pthread_join %d", rc);
}
printf("Completed join with thread %d thread_return = %d\n",t,
thread_return );
}
while(1) ;
}
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.
There is not much documentation regarding implementation of threading
in ecos.
Thanking you in advance.
Jaiprakash N
next reply other threads:[~2001-08-25 4:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-25 4:09 Jaiprakash [this message]
2001-08-27 8:04 ` Trenton D. Adams
2001-09-06 13:08 ` Jonathan Larmour
2001-09-07 2:34 ` Nick Garnett
2001-09-07 12:41 ` Jonathan Larmour
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200108251135.RAA16753@inablers.net \
--to=jaiprakash@inablers.net \
--cc=ecos-discuss@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).