* [ECOS] Problem with cosine and multithread...
@ 2001-02-28 22:38 Carlos Eduardo dos Reis Rodrigues Sobrinho
2001-03-01 10:06 ` Jonathan Larmour
0 siblings, 1 reply; 3+ messages in thread
From: Carlos Eduardo dos Reis Rodrigues Sobrinho @ 2001-02-28 22:38 UTC (permalink / raw)
To: eCos Discuss
Hi again, I manage to compile eCos so I wrote a little program to try it:
-------------------------------------------
#include <cyg/kernel/kapi.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "led.h"
/* now declare (and allocate space for) some kernel objects,
like the two threads we will use */
cyg_thread thread_s[2]; /* space for two thread objects */
char stack[2][4096]; /* space for two 4K stacks */
/* now the handles for the threads */
cyg_handle_t cosine_handle, led_handle;
/* and now variables for the procedure which is the thread */
cyg_thread_entry_t cosine_prog, led_prog;
/* and now a mutex to protect calls to the C library */
cyg_mutex_t cliblock;
/* we install our own startup routine which sets up threads */
void cyg_user_start(void)
{
printf("Entering twothreads' cyg_user_start() function\n");
cyg_mutex_init(&cliblock);
cyg_thread_create(4, cosine_prog, (cyg_addrword_t) 0,
"Coseno", (void *) stack[0], 4096,
&cosine_handle, &thread_s[0]);
cyg_thread_create(4, led_prog, (cyg_addrword_t) 1,
"LED's", (void *) stack[1], 4096,
&led_handle, &thread_s[1]);
cyg_thread_resume(cosine_handle);
cyg_thread_resume(led_handle);
cyg_scheduler_start();
cyg_mutex_lock(&cliblock);
printf("Won't reach here ...??\n");
cyg_mutex_unlock(&cliblock);
}
void led_prog(cyg_addrword_t data)
{
int i=0;
do
{ /*yg_mutex_lock(&cliblock);
printf("Green Led On!!\nWaiting 3 seconds\n\n");
cyg_mutex_unlock(&cliblock);*/
LED_4_ON;
cyg_thread_delay(100);
/*cyg_mutex_lock(&cliblock);
printf("Green Led Off!!\nWaiting 0,03 seconds\n\n");
cyg_mutex_unlock(&cliblock);*/
LED_4_OFF;
cyg_thread_delay(100);
i++;
} while (i<=9);
}
void cosine_prog(cyg_addrword_t data)
{
int i=0;
cyg_mutex_lock(&cliblock);
printf("\nCosine of %d is %2.4g\n",i,cos(i));
cyg_mutex_unlock(&cliblock);
i++;
cyg_thread_delay(50);
}
----------------------------------
Don't know why but the led_prog runs great. The cosine_prog doesn't,It rans
once and then it doens't run anymore.
BTW how can I reset the board or anything similar so that every time I need
to run the prog in gdb I don't have to press the reset button.
Another question is how can I build a program without debug info and all
that .text and place it in flash so I can do a GO 0X4(where I dl the prog)
and ran it without the gdb if that possible.
Thanks in advance for the help.
Best regards Carlos Sobrinho
PS: One small question.What's the difference between cyg_thread thread_s[2];
char stack[2][4096] AND static cyg_thread thread_s[2]; static char
stack[2][4096]; and what does volatile do in C,Sorry for the anoying
questions that this should be for you but they aren't for me...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ECOS] Problem with cosine and multithread...
2001-02-28 22:38 [ECOS] Problem with cosine and multithread Carlos Eduardo dos Reis Rodrigues Sobrinho
@ 2001-03-01 10:06 ` Jonathan Larmour
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Larmour @ 2001-03-01 10:06 UTC (permalink / raw)
To: Carlos Eduardo dos Reis Rodrigues Sobrinho; +Cc: eCos Discuss
Carlos Eduardo dos Reis Rodrigues Sobrinho wrote:
>
> Another question is how can I build a program without debug info and all
> that .text and place it in flash so I can do a GO 0X4(where I dl the prog)
> and ran it without the gdb if that possible.
> Thanks in advance for the help.
Build it for ROM startup and program it like you would program the GDB stub
image.
> PS: One small question.What's the difference between cyg_thread thread_s[2];
> char stack[2][4096] AND static cyg_thread thread_s[2]; static char
> stack[2][4096]; and what does volatile do in C,Sorry for the anoying
> questions that this should be for you but they aren't for me...
"static" means whether the symbols are visible outside that compilation
unit.
But don't seek help for basic C questions like this. Buy a book, don't ask
here as this list is to do with eCos only. I won't be answering any more
simple questions like that.
Jifl
--
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <003f01c0a225$3d6a4c00$2901a8c0@JEFF>]
* Re: [ECOS] Problem with cosine and multithread...
[not found] <003f01c0a225$3d6a4c00$2901a8c0@JEFF>
@ 2001-02-28 23:01 ` Carlos Eduardo dos Reis Rodrigues Sobrinho
0 siblings, 0 replies; 3+ messages in thread
From: Carlos Eduardo dos Reis Rodrigues Sobrinho @ 2001-02-28 23:01 UTC (permalink / raw)
To: jeff; +Cc: eCos Discuss
You're right sorry. About the other questions could you help?
----- Original Message -----
From: Jeff Lasslett <jeff@datataker.com.au>
To: 'Carlos Eduardo dos Reis Rodrigues Sobrinho' <epilog@netc.pt>
Sent: Thursday, March 01, 2001 7:57 AM
Subject: RE: [ECOS] Problem with cosine and multithread...
> Your LED prog runs in a loop. Your cosine prog doesn't. When the
function
> finishes, the thread finishes.
> Easy.
> Just put a loop around the body of the cosine_prog.
>
> cheers,
> Jeff
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-03-01 10:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-28 22:38 [ECOS] Problem with cosine and multithread Carlos Eduardo dos Reis Rodrigues Sobrinho
2001-03-01 10:06 ` Jonathan Larmour
[not found] <003f01c0a225$3d6a4c00$2901a8c0@JEFF>
2001-02-28 23:01 ` Carlos Eduardo dos Reis Rodrigues Sobrinho
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).