1

I'm in the process of researching a topic that has to do with schedulers and VMs. I asked this question yesterday, and I need to know whether the same is possible in Java.

I was wondering, then, if I can change the task scheduler that maps tasks to the real OS threads in Java.

halfer
  • 19,824
  • 17
  • 99
  • 186
Dervin Thunk
  • 19,515
  • 28
  • 127
  • 217
  • what "task scheduler" in java? – jtahlborn Jun 27 '13 at 18:57
  • @jtahlborn: Hah. Just assumed Java had a task-based model of parallelism... it doesn't? (!) Are all just threads 1:1 to OS threads? – Dervin Thunk Jun 27 '13 at 19:14
  • 2
    Threads are 1:1 with OS threads in pretty much all modern jvms. there are third-party libraries w/ the concept of tasks/actors (like akka), but not much built into the jdk (i guess jdk 7 has the fork/join framework). so, in order to answer your question, you'd have to pick a specific task framework. – jtahlborn Jun 27 '13 at 19:31
  • @jtahlborn: Let us assume the thread pools in util.java.concurrent... What does the scheduling there? – Dervin Thunk Jun 27 '13 at 19:48
  • the OS, like i said. java threads are 1:1 with OS threads. – jtahlborn Jun 27 '13 at 19:54
  • @jtahlborn: Hm, back to the drawing board then. Thanks for your time. – Dervin Thunk Jun 27 '13 at 20:18
  • so why don't you directly interact with OS? or maybe you would have 2nd. agent application that do it so –  Jun 27 '13 at 21:09
  • See also http://stackoverflow.com/questions/3342863/controlling-the-java-scheduling-algorithm – Raedwald Jun 27 '13 at 22:08

1 Answers1

0

On Linux there is a one to one mapping of Java threads to operating system threads. So on Linux the Java thread scheduler is the kernel scheduler. So to change the Java thread scheduler you would have to alter the kernel. I believe Linux has several options for changing the behaviour of the kernel scheduler, which might be enough for what you need.

If you are really trying not to have that one to one mapping, you would have to alter the JVM.

As both the Linux kernel and JVM (the Open JDK version) are open source this is technically possible, although a lot of work.

Community
  • 1
  • 1
Raedwald
  • 46,613
  • 43
  • 151
  • 237