Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Nov. 16, 2005 11:22:02

y.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

multithread


Hello everybody
my program involved in multithread
but I have no any idea about it
in my program,there need two threads,and each
thread has a timer
when the timer is timeout ,it will awake the
corresponding thread,
and after the thread finished its work,it will
sleep again ,wait for its timer

can anybody will be so kind as to give me some
advise ?
an example may even better
Thanks in advance !
yeajchao







___________________________________________________________
雅虎免费G邮箱-中国第一绝无垃圾邮件骚扰超大邮箱http://cn.mail.yahoo.com_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#2 Nov. 16, 2005 15:26:24

Bryan C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

multithread


How accurate does your timer need to be? If it doesn't have to be very
precise, I would do something like...

gpointer my_thread(gpointer anything)
{
gboolean exit_flag=TRUE;


while(exit_flag==FALSE)
{
exit_flag=do_work();
sleep(timer_length);
}

g_thread_exit(anything);
}

Bryan

yeajchao wrote:
> Hello everybody
> my program involved in multithread
> but I have no any idea about it
> in my program,there need two threads,and each
> thread has a timer
> when the timer is timeout ,it will awake the
> corresponding thread,
> and after the thread finished its work,it will
> sleep again ,wait for its timer
>
> can anybody will be so kind as to give me some
> advise ?
> an example may even better
> Thanks in advance !
> yeajchao
>
>
>
>
>
>
>
> ___________________________________________________________
> 雅虎免费G邮箱-中国第一绝无垃圾邮件骚扰超大邮箱
>http://cn.mail.yahoo.com>
> _______________________________________________
> gtk-list mailing list
> gtk-l***@*nome.org
>http://mail.gnome.org/mailman/listinfo/gtk-list_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#3 Nov. 17, 2005 11:15:23

Chris V.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

multithread


On Wednesday 16 November 2005 11:21, yeajchao wrote:
> Hello everybody
> my program involved in multithread
> but I have no any idea about it
> in my program,there need two threads,and each
> thread has a timer
> when the timer is timeout ,it will awake the
> corresponding thread,
> and after the thread finished its work,it will
> sleep again ,wait for its timer
>
> can anybody will be so kind as to give me some
> advise ?
> an example may even better

For the timer, you may be able to use g_timeout_add_full(), depending on what
timeout accuracy you want.

For doing the work, you could consider using a thread pool, so you do not have
to create a new thread with each timeout. Seehttp://developer.gnome.org/doc/API/2.0/glib/glib-Thread-Pools.htmlChris

_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support