For some reason I can not get the suspend_thread() call to work. I already
found that spawn_thread() does not work in the kernel driver code, instead I
had to use spawn_kernel_thread() in the code as:
Thread_ID[Thread_Counter]=spawn_kernel_thread( Raw_Image, "Compress",
B_NORMAL_PRIORITY, NULL);
So I am wondering if there is a different call to use on kernel threads to
suspend them. If I use the following code to try and start and stop my threads
as far as I can tell the threads never stop running. I even checked
...Kernel/Export.h to see if there was a different call.
for ( Thread_Counter=0L; Thread_Counter < MAX_THREADS; Thread_Counter++)
{ // Get compression threads setup.
Thread_Status=resume_thread(Thread_ID[Thread_Counter]); } }
// Use the active threads to compress data.
for ( Thread_Counter=0L; Thread_Counter < MAX_THREADS; Thread_Counter++)
{ // Get compression threads setup.
Thread_Status=suspend_thread(Thread_ID[Thread_Counter]); } // B_LOW_PRIORITY
The thing is the compression works fine, I can see a proper speedup if I go
from 1 thread to 2 threads to 4 threads, but after the compression is done the
threads are still running taking up CPU time. I also tried turning down the
priority of the threads but while other programs will now work well when I have
no other programs running the CPUs are still running and using power.
Does anyone know of another way to suspend kernel threads? I will try
semaphores next to see if that works.
PS. I am top posting because the Yahoo email service I am using.
From: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
To: haiku-3rdparty-dev <haiku-3rdparty-dev@xxxxxxxxxxxxx>
Sent: Tuesday, April 19, 2016 8:01 AM
Subject: [haiku-3rdparty-dev] Re: Multi-Threaded Code
I've questioned myself a similar question recently, how it compares to
acquiring a lock to a semaphore? Is there any reason I should use resume_thread
over releasing a semaphore?