• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Threading in multiple CPUs  RSS feed

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In multi CPU environment how does threading work, and how does the allocation of threads/process take place across different CPUs
 
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

how does threading work



I don't get your question. What do you mean by threading? Could you provide some more details?

how does the allocation of threads/process take place across different CPUs


It's an implementation detail of the OS and the scheduler in question. Why do you need to know this? Also if at all you need to know this, you can do a complex testing on the system in question and after many days ( if not months ) of testing, you might get an idea. And then it may change as well. I hope you know that a process and a thread are two different things?


Chan.
 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chan thanks for quick and blunt answer. I should have put some more details in question, which i initially though would be obvious.

Let us say we have process p1 and p2. Each process can spawn threads t1....tn. Let us also assume i am working 2 processor environment with all other conditions(single & double processor) being same.

Let us say p1 is running on processor1 and p2 is running on processor2. p1 spawns threads t1,t2 and p2 spawn threads p3,p4.

question: When p1 spawns threads the does it run on a specific processor or can it switch the processors. I understand that it will depend on the environment(OS), but theoretically how does it work.

If i have to use concepts like synchronization, wait , sleep, join, notify etc. do i need to worry about the numbers of processors, or all the details are abstracted from user, and OS takes care of the stuff.
 
Sheriff
Posts: 23876
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Naresh Chaurasia wrote:If i have to use concepts like synchronization, wait , sleep, join, notify etc. do i need to worry about the numbers of processors, or all the details are abstracted from user, and OS takes care of the stuff.



You'll notice that the Thread class in Java doesn't have any methods which refer to processors, multiple or otherwise, in any way. Which means that how the JVM and the Thread class and the operating system will deal with allocating threads to processors is completely hidden from you.

And if you look farther I expect you'll see that the tutorials about Thread don't mention anything about that issue either. Another hint that it's none of your business.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!