This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: Task suspension and resumption in POSIX
- From: "Ali, Khurram" <Khurram_Ali at mentorg dot com>
- To: "Gary Thomas" <gary at mlbassoc dot com>
- Cc: "eCos Discussion" <ecos-discuss at ecos dot sourceware dot org>
- Date: Fri, 8 Apr 2005 11:39:24 -0500
- Subject: RE: [ECOS] Task suspension and resumption in POSIX
I am actually creating an API that can be called by multiple threads
simultaneously. This includes threads that my code may have not created.
I was actually using semaphores myself previously. I associated a
semaphore with a task.
However, an application task that is not created in my code does not
have an associated semaphore. How do I suspend this task? I would have
to associate semaphores with a task within the suspend function. This
would mean I would have to create a semaphore at each call to suspend
and delete it in each call to resume. Or I would have to have a pool of
semaphores.
I just thought that if I could do something as simple as what I am doing
below.
-----Original Message-----
From: Gary Thomas [mailto:gary@mlbassoc.com]
Sent: Friday, April 08, 2005 11:26 AM
To: Ali, Khurram
Cc: eCos Discussion
Subject: RE: [ECOS] Task suspension and resumption in POSIX
On Fri, 2005-04-08 at 11:18 -0500, Ali, Khurram wrote:
> Thank you for the quick reply.
>
> I actually just want to do a self-suspend. And another task resumes
the
> suspended task.
Why not use the synchronization primitives, e.g. semaphores, that
were designed for just this sort of operation?
>
> I added the following functions in thread.cxx. It suspends. Just does
> not resume!
>
>
//----------------------------------------------------------------------
> ----
> // Suspend thread.
> externC int pthread_suspend ( void )
> {
> PTHREAD_ENTRY();
>
>
> pthread_info *info = pthread_self_info();
>
>
> // suspend the thread.
> info->thread->suspend();
>
>
> return ( 0 );
> }
>
>
>
//----------------------------------------------------------------------
> ----
> // Resume thread.
> externC int pthread_resume ( pthread_t thread1 )
> {
> PTHREAD_ENTRY();
>
>
> pthread_info *info = pthread_info_id( thread1 );
>
>
> //resume thread.
> if(info != NULL)
> {
> info->thread->resume();
>
>
> return ( 0 );
> }
> else
> return ( -1 );
> }
>
> Thank you,
> Khurram
>
> -----Original Message-----
> From: nickg@xl5.calivar.com [mailto:nickg@xl5.calivar.com] On Behalf
Of
> Nick Garnett
> Sent: Friday, April 08, 2005 11:09 AM
> To: Ali, Khurram
> Cc: ecos-discuss@sources.redhat.com
> Subject: Re: [ECOS] Task suspension and resumption in POSIX
>
> "Ali, Khurram" <Khurram_Ali@mentorg.com> writes:
>
> > Hello,
> >
> > I have two questions:
> >
> > 1) I am trying to suspend resume posix threads. I do not see the
> signals
> > for suspending and resuming threads in POSIX. Any ideas on how I can
> > suspend the threads?
>
> These are not implemented, they are part of the job control mechanism
> which is not supported in eCos.
>
> If you need to to stop and start threads you should really be doing it
> using explicit synchronization mechanisms. Stopping and starting
> threads without their cooperation is usually a bad idea, since you
> don't know what state they are in and it can lead to deadlock.
>
> >
> > 2) I am using insight to debug my applications. I can debug anything
> in
> > the main thread. But as soon as I put a break point in a thread that
I
> > create from main, insight hangs. Any ideas on how to do this?
>
> I cannot really help here except to suggest trying it from a
> commandline-only GDB, which may give you more information about what
> is happening.
>
>
> --
> Nick Garnett eCos Kernel Architect
> http://www.ecoscentric.com The eCos and RedBoot experts
>
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss