This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Using a Mix of Posix and native calls.
- From: Nick Garnett <nickg at ecoscentric dot com>
- To: "Venkateswara Rao L." <lvenkat at lvl7 dot com>
- Cc: <ecos-discuss at ecos dot sourceware dot org>
- Date: 26 Apr 2007 10:50:21 +0100
- Subject: Re: [ECOS] Using a Mix of Posix and native calls.
- References: <FE7FB54DCB7C6949A1D3F9FF22DA6C135097E2@lvl7in-mail01.lvl7.com>
"Venkateswara Rao L." <lvenkat@lvl7.com> writes:
> Hi,
>
> I've just started working on ecos. I've a basic query.
>
>
>
> Suppose, we use ecos native call(cyg_thread_create) to create a
> task(TASK A). We have another timer task that implements the software
> timers.
>
> We have a func. timerAdd(), that sets the timeout call. It uses
> pthread_cleanup_push with actual "internal timer add function" as
> argument, followed by pthread_cleanup_pop(1) to execute the registered
> handler. The function timerAdd() is called in the context of TASK A.
> We are getting exception while executing pthread push and pop
> instructions. It looks to me that this exception might be happening
> because the task which makes a call to the above mentioned posix calls,
> was not created using posix pthread routines.
>
>
>
> Is my understanding correct? Can we have a mix of posix and native calls
> under some conditions?
In general, you can call non-POSIX functions from POSIX threads, but
you cannot call POSIX functions from non-POSIX threads. This is
because POSIX threads have extra state associated with them such as
signal masks, per-thread data, and the root of the cleanup stack. This
latter item is what was missing when you attempted to use
pthread_cleanup_* from an non-POSIX thread. So you need to make that
thread a POSIX thread.
--
Nick Garnett eCos Kernel Architect
eCosCentric Limited http://www.eCosCentric.com/ The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss