JDWP thread suspending user java threads

Discussion in 'Java' started by Ethan, Jun 30, 2010.

  1. Ethan

    Ethan Guest

    Hi,

    I came to know that JDWP thread is used for debugging and that it is
    used by the debugger to suspend other user java threads. In a previous
    post, it seems like most modern JVMs leave thread management to their
    native OS, hence it wouldn't be possible for JDWP to directly suspend
    other user java threads and it could at the best hope to have them
    finish their work and move out of ready queue.

    If this is the case, how would it work with a java thread that is in
    an infinite loop, good enough to ensure that it doesn't finish at all?
    If not please share any links as to how it works. TIA.
     
    Ethan, Jun 30, 2010
    #1
    1. Advertising

  2. Ethan

    Arne Vajhøj Guest

    On 29-06-2010 21:45, Ethan wrote:
    > I came to know that JDWP thread is used for debugging and that it is
    > used by the debugger to suspend other user java threads. In a previous
    > post, it seems like most modern JVMs leave thread management to their
    > native OS, hence it wouldn't be possible for JDWP to directly suspend
    > other user java threads and it could at the best hope to have them
    > finish their work and move out of ready queue.
    >
    > If this is the case, how would it work with a java thread that is in
    > an infinite loop, good enough to ensure that it doesn't finish at all?
    > If not please share any links as to how it works.


    If the native thread API allows for suspension then the JVM
    can use that.

    Otherwise I guess that it would need to get something
    put in the code running in the thread.

    Arne
     
    Arne Vajhøj, Jun 30, 2010
    #2
    1. Advertising

  3. "Arne Vajhøj" <> wrote in message
    news:4c2aab72$0$281$...
    > On 29-06-2010 21:45, Ethan wrote:
    >> I came to know that JDWP thread is used for debugging and that it is
    >> used by the debugger to suspend other user java threads. In a previous
    >> post, it seems like most modern JVMs leave thread management to their
    >> native OS, hence it wouldn't be possible for JDWP to directly suspend
    >> other user java threads and it could at the best hope to have them
    >> finish their work and move out of ready queue.
    >>
    >> If this is the case, how would it work with a java thread that is in
    >> an infinite loop, good enough to ensure that it doesn't finish at all?
    >> If not please share any links as to how it works.

    >
    > If the native thread API allows for suspension then the JVM
    > can use that.
    >
    > Otherwise I guess that it would need to get something
    > put in the code running in the thread.


    The JVM is (mostly) an interpreter; that gives it control over all the
    threads.
     
    Mike Schilling, Jun 30, 2010
    #3
  4. Ethan

    Arne Vajhøj Guest

    On 29-06-2010 22:33, Mike Schilling wrote:
    > "Arne Vajhøj" <> wrote in message
    > news:4c2aab72$0$281$...
    >> On 29-06-2010 21:45, Ethan wrote:
    >>> I came to know that JDWP thread is used for debugging and that it is
    >>> used by the debugger to suspend other user java threads. In a previous
    >>> post, it seems like most modern JVMs leave thread management to their
    >>> native OS, hence it wouldn't be possible for JDWP to directly suspend
    >>> other user java threads and it could at the best hope to have them
    >>> finish their work and move out of ready queue.
    >>>
    >>> If this is the case, how would it work with a java thread that is in
    >>> an infinite loop, good enough to ensure that it doesn't finish at all?
    >>> If not please share any links as to how it works.

    >>
    >> If the native thread API allows for suspension then the JVM
    >> can use that.
    >>
    >> Otherwise I guess that it would need to get something
    >> put in the code running in the thread.

    >
    > The JVM is (mostly) an interpreter; that gives it control over all the
    > threads.


    I would have expected it to be JIT compiled.

    But I think you are correct - when executing under the debugger
    it will probably interpret.

    Arne
     
    Arne Vajhøj, Jun 30, 2010
    #4
  5. In article
    <>,
    Ethan <> wrote:

    > Hi,
    >
    > I came to know that JDWP thread is used for debugging and that it is
    > used by the debugger to suspend other user java threads. In a previous
    > post, it seems like most modern JVMs leave thread management to their
    > native OS, hence it wouldn't be possible for JDWP to directly suspend
    > other user java threads and it could at the best hope to have them
    > finish their work and move out of ready queue.
    >
    > If this is the case, how would it work with a java thread that is in
    > an infinite loop, good enough to ensure that it doesn't finish at all?
    > If not please share any links as to how it works. TIA.


    HotSpot sprinkles "safepoint polling" throughout the native code so it
    can have features like interpreted code. Seeing the safepoint set
    executes some code to tidy up the stack frame, acknowledge the
    safepoint, and suspend the thread. It's how GC operates safely and it's
    how you can get a stack trace from a running thread.

    It's up to the HotSpot optimizer to calculate where these checks need to
    be. There have been a few JVM builds where those calculations have been
    wrong.
    --
    I won't see Google Groups replies because I must filter them as spam
     
    Kevin McMurtrie, Jun 30, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marco Lorenzini
    Replies:
    0
    Views:
    398
    Marco Lorenzini
    May 13, 2004
  2. Jeffrey Hiess

    How can I "peek" at the keyboard without suspending?

    Jeffrey Hiess, Nov 26, 2003, in forum: C Programming
    Replies:
    11
    Views:
    722
    Irrwahn Grausewitz
    Dec 2, 2003
  3. Maciej
    Replies:
    1
    Views:
    680
    Thomas Hawtin
    Oct 27, 2006
  4. Replies:
    8
    Views:
    1,216
  5. Replies:
    5
    Views:
    411
    Arne Vajhøj
    Jun 26, 2008
Loading...

Share This Page