473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SDL threads and gcc optimization

41
Hi!

My program (a raytracer) needs a lot of calculations so i thought it would be a good idear to use threads. I'm allready using the SDL lib in the program so the SDL threads seemed a good choice.
The program runs fine and a faster with treads, but it's still to slow. I tried speeding it up with the gcc optimization flags, but that just makes the program lock up. The optimization falgs works fine if i don't use threads.
I thought this might be a gcc thing so i tried compiling with visual studio, but with the exact same result: the program locks up right after it's started and i need to kill it, in order to close it.
During the lock up the program seems to run (~100% CPU usage).

- Has anyone tried to use the SDL threads alongside with compiler optimization?
- Can you recomend another way of using threads other than SDL, that would work better?

Thanks!
- JonLT
Apr 1 '08 #1
2 2449
gpraghuram
1,275 Expert 1GB
I havent used SDL thread..
Why cant you try to use POSIX or ACE Framework thread for this?


Raghuram
Apr 2 '08 #2
JonLT
41
Thanks for your reply!

I just thought it would be easier to use the sdl threads. SDL is also crossplatform, which is importent, because we are developing as a group, and we use different OS's.

A small correction to the initial post. When the program locks up, it only uses one core.
This is the output from the gdb debugger:
Expand|Select|Wrap|Line Numbers
  1. [Thread debugging using libthread_db enabled]
  2. [New Thread -1215969088 (LWP 12883)]
  3.  
  4. ... some output from the program before it reaches the main loop (not using threads)...
  5.  
  6. [New Thread -1314067568 (LWP 12886)]
  7. [New Thread -1322460272 (LWP 12887)]
  8. [New Thread -1330852976 (LWP 12888)]
  9. [New Thread -1339245680 (LWP 12889)]
  10. [New Thread -1347638384 (LWP 12890)]
  11. [New Thread -1356031088 (LWP 12891)]
  12. [Thread -1339245680 (LWP 12889) exited]
  13. [Thread -1330852976 (LWP 12888) exited]
  14. [Thread -1322460272 (LWP 12887) exited]
  15. [Thread -1347638384 (LWP 12890) exited]
  16. [Thread -1356031088 (LWP 12891) exited]
  17. [Thread -1314067568 (LWP 12886) exited]
  18.  
After this nothing happens, it just hangs.
This looks like the treads are only created the first time the main-loop is run, and not in every loop.
As i said in the initial post, this only happens when the optimization flag is turned on in the compiler.
Does anyone have an idea to what might be happening?
Apr 2 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: Dennis Owens | last post by:
I am trying to run a thread off of a form, and every once in a while the thread will raise an event for the form to read. When the form gets the event, the form will place the event into a dataset...
9
by: Rune | last post by:
Is it best to use double quotes and let PHP expand variables inside strings, or is it faster to do the string manipulation yourself manually? Which is quicker? 1) $insert = 'To Be';...
6
by: kracchh | last post by:
Hi, the following .NET 1.1 C#-program does not terminate (opposed to what I would expect): -------- using System; using System.Threading; public class Test {
7
by: Michael | last post by:
I'm writing an application that decodes a file containing binary records. Each record is a particular event type. Each record is translated into ASCII and then written to a file. Each file contains...
5
by: wkaras | last post by:
I've compiled this code: const int x0 = 10; const int x1 = 20; const int x2 = 30; int x = { x2, x0, x1 }; struct Y {
12
by: Dave | last post by:
Hi all, I have an application which has some worker threads which often have to stop and wait for some further information from other threads. These pauses will often take a long time (a couple...
167
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an...
10
by: S James S Stapleton | last post by:
Is volatile necessary anymore? I have a two-thread piece of code I've been testing to figure out what volatile does (fairly simple code, uses pthreads). I have an update thread (variables passed as...
20
by: Ravikiran | last post by:
Hi Friends, I wanted know about whatt is ment by zero optimization and sign optimization and its differences.... Thank you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.