<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">It's been a while since I use pthreads directly, but the modus operandi of condition variables is that you declare one before the<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">threads that use it are started, and the threads that you want to wait will call wait() to pause until the another thread signals a change,<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">and then you would check the condition variable value to see if it is the desired value to proceed. <br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 23, 2016 at 11:52 AM, Christopher Hagler <span dir="ltr"><<a href="mailto:haglerchristopher@gmail.com" target="_blank">haglerchristopher@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I am working on a home automation project written in C. It allows a user to automate daily task with open source hardware and software. However, since I am lacking experience with pthreads, I have run into a couple of issues that I cant seem to resolve. The intentions of the code where the issues reside are:<div><br><div>The project allows drivers to be written as shared objects that, which in turn, will control a remote hardware device or devices with all communication happening through shared memory. The Scheduler module will take the shared object, and schedule it to run via process queues. Once the process, a struct containing the shared object and an abstraction for a pthread, runs for its time slot, the scheduler will stop the process and place it in another process queue. The whole idea was to simulate an operating system scheduler because potentially there could be a few hundred threads. This is where the first issue resides. I am having trouble putting the process to sleep. I have done some research on pthreads and supposedly this can be accomplished via pthread condition variables. This is the solution I have attempted, and apparently I have not implemented it correctly. It will start the process which will run, but when I try to put it to sleep, it keeps running.</div></div><div><br></div><div>The second issue is when ever you run the program, it fails to link the shared object sometimes. However, if you have to quickly run the program back-to-back, it will start and run fine. I am not sure why this is happening. It could possibly be linked to my setup, but I am not sure. I am running Opensuse in Virtual Box. </div><div><br></div><div>Any advice on these issues would be greatly appreciated. I also know there are a couple of people who have been wanting to learn C, and you are more than welcome to join the project if you want.</div><div><br></div><div>The code base: <a href="https://github.com/haglerchristopher/automation/tree/development" target="_blank">https://github.com/haglerchristopher/automation/tree/development</a></div><div><br></div><div>Thanks for the help.</div></div>
<br>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" rel="noreferrer" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" rel="noreferrer" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Pete Hardie<br>--------<br>Better Living Through Bitmaps</div>
</div>