Deadlock?

P

Philip Mak

I have a multi-threaded http server. Sometimes, it gets into a state
where it stops responding to requests, and if I press Ctrl+C at the
console it takes a long time to respond. The "ruby -rprofile" shows
this at the top:

% cumulative self self total
time seconds seconds calls ms/call ms/call name
62.65 1.04 1.04 30 34.67 853.00 Thread#stop
9.64 1.20 0.16 37 4.32 18.38 Kernel.require
9.04 1.35 0.15 1 150.00 220.00 IO#each
7.23 1.47 0.12 152 0.79 0.92 Kernel.sleep

I never call Thread#stop explicitly in my program so it's surprising
that Thread#stop takes up so much time... although I do have both
Timeout and Mutex.

Anyone know what to make of this 62.65% time consumption by
Thread#stop? Could it be that somehow my threads are deadlocking each
other?
 
N

nobu.nokada

Hi,

At Sun, 14 Sep 2003 14:59:27 +0900,
Philip said:
I never call Thread#stop explicitly in my program so it's surprising
that Thread#stop takes up so much time... although I do have both
Timeout and Mutex.

Mutex uses Thread#stop to wait to be unlocked.
Anyone know what to make of this 62.65% time consumption by
Thread#stop? Could it be that somehow my threads are deadlocking each
other?

Do you define the signal handler?
 
N

nobu.nokada

Hi,

At Sun, 21 Sep 2003 03:21:25 +0900,
Philip said:
Those should be executed fairly quickly, shouldn't they? Since I'm
just incrementing and decrementing a number.

Hmmm, seem so. Do you use just one mutex in the application?
The only signal handling code in my program is this, which happens in
the main thread:

["SIGTERM", "SIGINT"].each do |sig|
trap(sig) { shutdown }
end

What's `shutdown'? Doesn't anything deadlock in it?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,135
Messages
2,570,783
Members
47,341
Latest member
hanifree

Latest Threads

Top