public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] cyg_thread_resume
@ 2001-01-17 15:45 Paleologos Spanos
  2001-01-17 16:23 ` Jonathan Larmour
  0 siblings, 1 reply; 4+ messages in thread
From: Paleologos Spanos @ 2001-01-17 15:45 UTC (permalink / raw)
  To: ecos-discuss

 Hi,I have a problem using the cyg_thread_resume function.
I have configured the scheduler to have the bitmap scheduler.I tried to
modify the scheduler so as to test if it is possible to resume an exited
thread.However,the thread's state didn't change.
 What I did was to add after the if loop in line :161 in the sched.cxx
file the below code :
Cyg_Thread  *current = Cyg_Scheduler::get_current_thread();
     cyg_thread_kill ((cyg_handle_t) current); 
       cyg_thread_resume((cyg_handle_t) current);


I have 2 threads on the application level and I would expect that the
output should be

 execution of thread1
 (resume thread1)
 execution of thread1
 (resume thread1)
execution of thread1
....
....


 I tested these commands without the cyg_thread_resume and the thread was
stopped(because of the cyg_thread_kill i suppose).
 However adding  the command ofcyg_thread_resume does not restart the
thread.Why?

 What am I doing wrong?

 Thank you for your help in advance.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] cyg_thread_resume
  2001-01-17 15:45 [ECOS] cyg_thread_resume Paleologos Spanos
@ 2001-01-17 16:23 ` Jonathan Larmour
  2001-01-17 17:04   ` Paleologos Spanos
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Larmour @ 2001-01-17 16:23 UTC (permalink / raw)
  To: Paleologos Spanos; +Cc: ecos-discuss

Paleologos Spanos wrote:
> 
>  Hi,I have a problem using the cyg_thread_resume function.
> I have configured the scheduler to have the bitmap scheduler.I tried to
> modify the scheduler so as to test if it is possible to resume an exited
> thread.However,the thread's state didn't change.
>  What I did was to add after the if loop in line :161 in the sched.cxx
> file the below code :
> Cyg_Thread  *current = Cyg_Scheduler::get_current_thread();
>      cyg_thread_kill ((cyg_handle_t) current);
>        cyg_thread_resume((cyg_handle_t) current);
> 
> I have 2 threads on the application level and I would expect that the
> output should be
> 
>  execution of thread1
>  (resume thread1)
>  execution of thread1
>  (resume thread1)
> execution of thread1
> ....
> ....
> 
>  I tested these commands without the cyg_thread_resume and the thread was
> stopped(because of the cyg_thread_kill i suppose).
>  However adding  the command ofcyg_thread_resume does not restart the
> thread.Why?
> 
>  What am I doing wrong?

Uh... you just killed yourself so you aren't running any more, so how can
you then resume? Another thread has to resume you.

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Un cheval, pas du glue. Pas du cheval, beaucoup du glue. || Opinions==mine

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] cyg_thread_resume
  2001-01-17 16:23 ` Jonathan Larmour
@ 2001-01-17 17:04   ` Paleologos Spanos
  2001-01-17 18:17     ` Jonathan Larmour
  0 siblings, 1 reply; 4+ messages in thread
From: Paleologos Spanos @ 2001-01-17 17:04 UTC (permalink / raw)
  To: Jonathan Larmour; +Cc: ecos-discuss

 As I mentioned the cyg_thread_kill and cyg_thread_resume are called by
the scheduler and not by a thread.
 Actually I want my scheduler  to stop a desired thread and restart it
from the beginning(resume it at a desired point in time and start
execution from the starting point of the thread's code.)


                           Thank you.
On Thu, 18 Jan 2001, Jonathan Larmour wrote:

> Paleologos Spanos wrote:
> > 
> >  Hi,I have a problem using the cyg_thread_resume function.
> > I have configured the scheduler to have the bitmap scheduler.I tried to
> > modify the scheduler so as to test if it is possible to resume an exited
> > thread.However,the thread's state didn't change.
> >  What I did was to add after the if loop in line :161 in the sched.cxx
> > file the below code :
> > Cyg_Thread  *current = Cyg_Scheduler::get_current_thread();
> >      cyg_thread_kill ((cyg_handle_t) current);
> >        cyg_thread_resume((cyg_handle_t) current);
> > 
> > I have 2 threads on the application level and I would expect that the
> > output should be
> > 
> >  execution of thread1
> >  (resume thread1)
> >  execution of thread1
> >  (resume thread1)
> > execution of thread1
> > ....
> > ....
> > 
> >  I tested these commands without the cyg_thread_resume and the thread was
> > stopped(because of the cyg_thread_kill i suppose).
> >  However adding  the command ofcyg_thread_resume does not restart the
> > thread.Why?
> > 
> >  What am I doing wrong?
> 
> Uh... you just killed yourself so you aren't running any more, so how can
> you then resume? Another thread has to resume you.
> 
> Jifl
> -- 
> Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
> Un cheval, pas du glue. Pas du cheval, beaucoup du glue. || Opinions==mine
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] cyg_thread_resume
  2001-01-17 17:04   ` Paleologos Spanos
@ 2001-01-17 18:17     ` Jonathan Larmour
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Larmour @ 2001-01-17 18:17 UTC (permalink / raw)
  To: Paleologos Spanos; +Cc: ecos-discuss

Paleologos Spanos wrote:
> 
>  As I mentioned the cyg_thread_kill and cyg_thread_resume are called by
> the scheduler and not by a thread.
>  Actually I want my scheduler  to stop a desired thread and restart it
> from the beginning(resume it at a desired point in time and start
> execution from the starting point of the thread's code.)
> 
>                            Thank you.
> On Thu, 18 Jan 2001, Jonathan Larmour wrote:
> 
> > Paleologos Spanos wrote:
> > >
> > >  Hi,I have a problem using the cyg_thread_resume function.
> > > I have configured the scheduler to have the bitmap scheduler.I tried to
> > > modify the scheduler so as to test if it is possible to resume an exited
> > > thread.However,the thread's state didn't change.
> > >  What I did was to add after the if loop in line :161 in the sched.cxx
> > > file the below code :
> > > Cyg_Thread  *current = Cyg_Scheduler::get_current_thread();
> > >      cyg_thread_kill ((cyg_handle_t) current);
> > >        cyg_thread_resume((cyg_handle_t) current);


Okay, some more detail: if you call cyg_thread_kill with the current
thread, then that will call cyg_thread_exit for the current thread.
cyg_thread_exit does not return. Look at the code for Cyg_Thread::exit() in
kernel/VERSION/src/common/thread.cxx

The scheduler is not a separate entity, the scheduler functions are called
in a thread context.

For what you want to achieve (stop and resume a thread from the beginning),
you want to call cyg_thread_kill() and cyg_thread_resume() from a
_different_ thread, not from the "scheduler" which will actually be the
same thread.

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Un cheval, pas du glue. Pas du cheval, beaucoup du glue. || Opinions==mine

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-01-17 18:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-17 15:45 [ECOS] cyg_thread_resume Paleologos Spanos
2001-01-17 16:23 ` Jonathan Larmour
2001-01-17 17:04   ` Paleologos Spanos
2001-01-17 18:17     ` Jonathan Larmour

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).