Mercurial > flash_v2
view examples/twothreads.c @ 1423:440ddbf97b39
2003-09-21 Jonathan Larmour <jifl@eCosCentric.com>
* cdl/hal_sh.cdl: CYGHWR_HAL_SH_FPU_REGS is only needed if there's an
FPU.
* include/hal_var_bank.h (HAL_THREAD_INIT_CONTEXT_FPU): Use FPSCR
init value from HAL register definitions.
2003-09-19 John Dallaway <jld@ecoscentric.com>
* cdl/hal_sh.cdl: Specify default CDL values for sh4_202_md target.
2003-09-11 Nick Garnett <nickg@ecoscentric.com>
* include/hal_var_bank.h (HAL_THREAD_INIT_CONTEXT_FPU): Changed
initial value of fpscr to do round-to-nearest rather than
round-to-zero.
2003-09-08 Nick Garnett <nickg@ecoscentric.com>
* src/vectors.S (cyg_hal_default_exception_vsr): Added code to
switch to interrupt stack when fielding exceptions from RedBoot or
some other ROM monitor. Without this we get potential stack
overflows when debugging via the network.
2003-09-05 Nick Garnett <nickg@ecoscentric.com>
* include/hal_arch.h:
* include/hal_var_bank.h:
* include/hal_var_bank.inc:
* src/context.S:
Added support for floating point state save and restore and GDB
* src/hal_misc.c (hal_delay_us): Fixed implementation of this
routine so that it actually works.
* src/hal_syscall.c:
Added support for all supportable syscalls.
* src/sh_stub.c:
Added check in __is_bsp_syscall() for trap 34 traps using the TRA
register.
* src/vectors.S: Set startup stack size to the same as the
interrupt stack size. In some configurations of RedBoot the
previous value was too small.
* include/sh_stub.h:
Fixed HAL_STUB_PLATFORM_STUBS_FIXUP() to only rewind for a
breakpoint. Traps are not rewound.
* cdl/hal_sh.cdl: Added option for SH architecture FP register
count.
| author | nickg |
|---|---|
| date | Fri, 05 Dec 2003 17:06:23 +0000 |
| parents | ead06911cbae |
| children |
line wrap: on
line source
#include <cyg/kernel/kapi.h> #include <stdio.h> #include <math.h> #include <stdlib.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 simple_threadA, simple_threadB; /* and now variables for the procedure which is the thread */ cyg_thread_entry_t simple_program; /* 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, simple_program, (cyg_addrword_t) 0, "Thread A", (void *) stack[0], 4096, &simple_threadA, &thread_s[0]); cyg_thread_create(4, simple_program, (cyg_addrword_t) 1, "Thread B", (void *) stack[1], 4096, &simple_threadB, &thread_s[1]); cyg_thread_resume(simple_threadA); cyg_thread_resume(simple_threadB); } /* this is a simple program which runs in a thread */ void simple_program(cyg_addrword_t data) { int message = (int) data; int delay; printf("Beginning execution; thread data is %d\n", message); cyg_thread_delay(200); for (;;) { delay = 200 + (rand() % 50); /* note: printf() must be protected by a call to cyg_mutex_lock() */ cyg_mutex_lock(&cliblock); { printf("Thread %d: and now a delay of %d clock ticks\n", message, delay); } cyg_mutex_unlock(&cliblock); cyg_thread_delay(delay); } }
