• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Threading in multiple CPUs

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic