Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 59721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:02:59+00:00 2026-05-10T18:02:59+00:00

I have been tinkering with BSP trees for a while now and am also

  • 0

I have been tinkering with BSP trees for a while now and am also playing with threads. When adding a triangle to a BSP tree, an opportunity arises to create a new thread for the purposes of processing data in parallel.

 insert(triangle, bspnode) {   ....   else if(triangle spans bspnode)   {     (frontpiece, backpiece) = plane_split(triangle, bspnode)      insert(frontpiece, bspnode.front)     insert(backpiece, bspnode.back)   }   .... } 

The two insert operations above could be executed by two threads, and since they do not modify the same data, cheap synchronization can be used.

 insert(triangle, bspnode) {   ....   else if(triangle spans bspnode)   {     (frontpiece, backpiece) = split(triangle, bspnode)      handle = beginthread(insert(backpiece, bspnode.front))     insert(frontpiece, bspnode.back)     if(handle)     {       waitforthread(handle)     }     else     {       insert(backpiece, bspnode.front)     }   }   .... } 

This new method attempts to create a thread to complete the operation in parallel, but should not fail if the thread cannot be created (it will simply revert to the original algorithm).

Is this a sound programming practice, or am I using threads improperly? I have not been able to find any literature on this technique. I like that it tends to use my CPU to its fullest (2 cores), and would theoretically scale to any number of processors available. I don’t like that it might be horribly wasteful on CPU and memory.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:02:59+00:00Added an answer on May 10, 2026 at 6:02 pm

    Threads are great if some part of the processing is waiting on something external (user input, I/O, some other processing) – the thread that’s waiting can continue to wait, while a thread that isn’t waiting forges on ahead.

    However, for processing-intensive tasks, more threads than processors actually creates overhead. It seems like your threads are doing all ‘CPU work’, so I’d stick to one thread per core – test to find the optimal number, though.

    The biggest overhead created is from context switching (freezing one thread and loading the execution context of the next one), as well as cache misses when threads are doing tasks with different memory (if your thread can use the CPU cache effectively).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a private project I've been tinkering with for a while. I'm thinking
We have been using CruiseControl for quite a while with NUnit and NAnt. For
I have been tinkering with javasript (jquery) all day. I want to create a
Have been using it for a while with CodeIgniter and I can't remember if
I have been tinkering with the following script: # -*- coding: utf8 -*- import
I have been tinkering around with PDF::API2 and i am facing a problem, create
Greetings stackoverflow. I have been tinkering about with a SOAP client using PHP5's native
Have been looking at the MVC storefront and see that IQueryable is returned from
Have been studying the file system related classes of Adobe AIR 1.5, but so
I have been experimenting with woopra.com A web analytics tool. Which requires a piece

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.