Search code examples
javalinux-kerneljvmblocking

Is it possible to know if a process is waiting in Blocked state on a Receive() call on Linux?


My main purpose is to execute processes one by one in a round-robin fashion until one calls receive() and is blocked, so that the execution switches to the next process in the queue. There is a controller application which is coded in Java and it executes these processes(which are also Java applications) using Runtime.getRuntime().exec() and keeps the return values which are Process objects.

To achieve this purpose, I need to capture the receive() calls(or their states, which is blocked) and tell them to the controller(master) application.

I can go as low-level as you want if this is possible.. My first thought was to get this information from the driver and then tell it to my controller Java application. I have written a linux kernel network module which captures the send and receive operations, but AFAIK the socket.receive() function does not tell anything to the network driver.

So, I think the options are to get this information from either the JVM, somehow get it from a linux command or so, or possibly through the linux kernel module?

What are your suggestions?


Solution

  • If you want to know if your threads are blocked, or exactly what they are blocked on, you can either take a thread dump or use a tool like jvisualvm to attach to the process and take a look (in jvisualvm you would attach to the process, take a thread dump, and then look at the activity of each thread).