Interrupt status
Dear,
I have found on http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4082705
"Interrupting a thread that is not alive need not have any effect."
and this for interrupted and isIinterrupted:
"A thread interruption ignored because a thread was not alive at the time
of the interrupt, will be reflected by this method returning false."
But I can't find where write something like:
No matter thread was interrupted or not while it was alive or not, if thread is not alive interrupted and isIinterrupted will always return false.
What I've wrote is correct (I've tried), but can someone help and tell me where I can find such a kind of information/documentation? Thank you.
But I can't find where write something like:
No matter thread was interrupted or not while it was alive or not, if thread is not alive interrupted and isIinterrupted will always return false.Then it isn't specified. The implementation you used may have worked that way but it isn't obliged to. So you shouldn't rely on it. Instead you should use t.isAlive() && t.isInterrupted().
But why would you care about the interrupt status of a thread that isn't alive anyway? I've never called Thread.interrupted() or Thread.isInterrupted() from anywhere except the current thread in over 10 years of Java. But obviously you can't call them on the current thread for a thread that isn't alive ...
Similar Messages
-
How to check the value of "The Interrupt Status Flag"?
Hi, thank you for reading this post!
Invoking Thread.interrupt() sets the value of the Interrupt Status Flag.
Just wondering if there is a Java method to check the value of this flag? Or is using isInterrupted() or interrupted() the only way to check?
http://download.oracle.com/javase/tutorial/essential/concurrency/interrupt.html
Thank you in advance for your help!
EricBelow is the full code. As soon as the Thread.sleep() is taken out in main(), the interrupt is detected in the child thread. But if the sleep() stays, then the child thread goes into an infinite loop. It's not detected the interrupt.
//ParentInterruptChildThreadCatchedDemo.java
//Program function: This program demonstrates the parent thread (main()) interrupting a child thread (thread1).
//Threaded class
class TryThread extends Thread {
//fields
private String threadname;
private long aWhile;
//Constructor
public TryThread(String tname, long delay) {
threadname = tname;
aWhile = delay;
//run() method
public void run() {
while(!Thread.interrupted()) {
//Do work
try {
System.out.println(Thread.currentThread().getName() + " was just interrupted!");
throw new InterruptedException();
} catch(InterruptedException e) {
//System.exit(1);
return;
public class ParentInterruptChildThreadCatchedDemo {
public static void main(String[] args) {
Thread thread1 = new TryThread("thread1", 2000L);
thread1.start();
try {
System.out.println("main() goes to sleep for 10 second.");
Thread.sleep(10000);
System.out.println("Statement after main() sleep().");
} catch(InterruptedException e) {
e.printStackTrace();
//Interrupt thread1
int interruptFlag = 5;
for(int i=0; i<11; i++) {
if(i == interruptFlag) {
System.out.println("Condition met, going to interrupt thread1 ...");
thread1.interrupt();
System.out.println("Thread1 interrupted!");
System.out.println("Ending main()");
/*Output:
main() goes to sleep for 10 second.
Statement after main() sleep().
Condition met, going to interrupt thread1 ...
Thread1 interrupted!
Ending main()
INFINITION LOOP
*/ -
Is interrupted status safe? please help.
I have read the section about interrupts in the Java Tutorial and the API documentation about the interrupt() method but I was unable to find the answer to this question.
I have two threads: thread1 and thread2
The run() method for thread1 is:
public void run() {
while(true) {
System.out.println("Hello");
if (Thread.currentThread().isInterrupted()) {
break;
System.out.println("Thread 1 ending");
}In each iteration, thread1 checks its interrupted status.
To stop the thread1, the thread2 executes the following:
thread1.interrupt();The methods interrupt() and isInterrupted() both access the interrupted status of thread1. Therefore the interrupted status of thread1 is a shared variable used by two threads. Is there any risk of inconsistency on the interrupted status caused by the concurrent access?
In other words:
I'm worried about the concurrent acces on the interrupted status variable.
Do the interrupt() and isInterrupted() methods take care of the synchronization on the interrupted status variable or should I use some synchronization mechanism?
Thank you very much for the help.the only thing i'd point out, is that you need to be careful which method you use to test the interrupt status. the isInterrupted() method checks the status and leaves the status alone, whereas the interrupted() method checks the status and then clears it. make sure you are using the version which has the behavior you desire.
other than that, i can't think of any other "idioms". i guess i will mention that generally you want to use wait/notify to coordinate threads ("normal" communication). interrupt should generally only be used be used when you want to stop the progress of a thread (abnormal communication, e.g. due to a problem). -
Common practice to stop thread - checking flag or checking interrupt status
Hello all, from the official document from Sun http://java.sun.com/j2se/1.4.2/docs/guide/misc/threadPrimitiveDeprecation.html , I was understand that the common practice to stop a thread is to
private class StockMonitor extends Thread {
public StockMonitor() {
thread = this;
public void run() {
final Thread thisThread = Thread.currentThread();
while(thisThread == thread) {
public void _stop() {
thread = null;
private volatile Thread thread;
}However, the need to have an extra flag is rather cumbersome. Hence, is it a common practice which we can stop a thread by checking its interrupt status? What is the pros and cons of the two methods?
Thanks
private class StockMonitor extends Thread {
public StockMonitor() {
thread = this;
public void run() {
final Thread thisThread = Thread.currentThread();
while(thisThread.isInterrupted()) {
public void _stop() {
interrupt();
}However, I thought checking thisThread.isInterrupted() is enough? As the following case...
public void run()
while(Thred.currentThread().isInterrupted())
// Do something
try {
Thread.sleep(1000);
catch(InterruptedException exp) {
// Must break while loop from here. This is because interrupted
// flag had been reset. If not, we will not able to
// exit this while loop.
break;
}So, is there any need for a boolean type status flag? Can you please provide me any case, where it is impossible to achieve by just using checking thisThread.isInterrupted() checking?
Message was edited by:
KwangHooi -
Why can't I interrupt the main thread from a child thread with this code?
I am trying to find an elegant way for a child thread (spawned from a main thread) to stop what its doing and tell the main thread something went wrong. I thought that if I invoke mainThread.interrupt() from the child thread by giving the child thread a reference to the main thread, that would do the trick. But it doesn't work all the time. I want to know why. Here's my code below:
The main class:
* IF YOU RUN THIS OFTEN ENOUGH, YOU'LL NOTICE THE "Child Please!" MESSAGE NOT SHOW AT SOME POINT. WHY?
public class InterruptingParentFromChildThread
public static void main( String args[] )
Thread child = new Thread( new ChildThread( Thread.currentThread() ) );
child.start();
try
child.join();
catch( InterruptedException e )
// THE LINE BELOW DOESN'T GET PRINTED EVERY SINGLE TIME ALTHOUGH IT WORKS MOST TIMES, WHY?
System.out.println( "Child please!" );
System.out.println( "ALL DONE!" );
The class for the child thread:
public class ChildThread implements Runnable
Thread mParent;
public ChildThread( Thread inParent )
mParent = inParent;
public void run()
System.out.println( "In child thread." );
System.out.println( "Let's interrupt the parent thread now." );
// THE COMMENTED OUT LINE BELOW, IF UNCOMMENTED, DOESN'T INVOKE InterruptedException THAT CAN BE CAUGHT IN THE MAIN CLASS' CATCH BLOCK, WHY?
//Thread.currentThread().interrupt();
// THIS LINE BELOW ONLY WORKS SOMETIMES, WHY?
mParent.interrupt();
}EJP wrote:
I'm not convinced about that. The wording in join() suggests that, but the wording in interrupt() definitely does not.Thread.join() doesn't really provide much in the way of details, but Object.wait() does:
"throws InterruptedException - if any thread interrupted the current thread +before+ or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown."
every jdk method i've used which throws InterruptedException will always throw if entered while a thread is currently interrupted. admitted, i rarely use Thread.join(), so it's possible that method could be different. however, that makes the thread interruption far less useful if it's required to hit the thread while it's already paused.
a simple test with Thread.sleep() confirms my expected behavior (sleep will throw):
Thread.currentThread().interrupt();
Thread.sleep(1000L); -
I want to get interrupt from my 6602 board, e.g. on a rising or
falling edge of an output.
I do register level programming. The RLPM does not fully describe all
related registers.
Does anyone have experience with this, or has the related
register-layout available?
I am looking for information about the:
Global Interrupt Control Register (address 0x770);
Global Interrupt Status Register (address 0x754);
Interrupt Acknowledge Register (address 0x4 for G0);
How do I specify I want an interrupt on an edge of the output, or on
an edge of the gate signal?
The Interrupt Enable Register only specifies TC (Terminal Count),
(address 0x092 for G0).
And how to acknowledge such an interrupt?
Thanks.This is the answer to my own questions, it is working:
GLOBAL_INTERRUPT_STATUS_REG = 0x754, // One register on each TIO chip |size:32bit
GLOBAL_INTERRUPT_CONTROL_REG = 0x770, // One register on each TIO chip |size:32bit
enum GlobalInterruptControlRegBits
EnableInterrupts = (1 << 31), // For TIO(0) and TIO(1)
CascadeInterrupts = (1 << 29), // For TIO(0), cacade interrupts from TIO(1) through TIO(0)
INTERRUPT_ENABLE_REG = 0x92// for G0, for G1..G3 see RLPM page 3-18, 3-19
enum InterruptEnableRegBits
TCInterruptEnableG02 = (1 << 6), // for counter G0, G2, G4, G6, see RLPM page 3-18
TCInterruptEnableG13 = (1 << 9), // for counter G1, G3, G5, G7, see RLPM page 3-19
GateInterruptEnable
G02 = (1 << 8), // for counter G0, G2, G4, G6, not in RLPM
GateInterruptEnableG13 = (1 << 10), // for counter G1, G3, G5, G7, not in RLPM
STATUS_REG = 0x04 // for G0, for G1..G3 see RLPM page 3-28
enum StatusRegBits
// see RLPM page 3-28
assertsInt = (1 << 15),
TCStatus = (1 << 3), // bit03
GateIntStatus = (1 << 2), // bit02 Not in RLPM,
InterruptAckReg = 0x04, // 0x004 (G0), 0x006 (G1), 0x104 (G2), 0x106 (G3) | Write-only | size:16bit
enum InterruptAckRegBits
// Not in RLPM
GateErrorConfirm = (1 << 5),
TCErrorConfirm = (1 << 6),
TCInterruptAck = (1 << 14),
GateInterruptAck = (1 << 15),
Have fun with it. -
Solaris 8 (INTEL) - Interrupt handler
We are developing a device driver for a PCI card. The interrupt level assigned is 10 and the priority level is 6.
In the interrupt handler, we first check whether our device has generated the interrupt and if not return with DDI_INTR_UNCLAIMED otherwise we proceed to clear the interrupt status and do the appropriate action and return DDI_INTR_CLAIMED.
we have observed that while returning from the Interrupt handler, the control is going into a function "LOOP2", and our interrupt handler is invoked again from "LOOP2" and this goes into a loop. ( We use kadb to debug ).
Kindly clarify.Hi!
I also had the same exact problem during the install. The only way that I could procede was to tell it that I didn't want to install networking. Now when I boot, it tries to load the elx0 driver (for my 3Com 3c509b) and brings the following message, "SIOCSLIFFFLAGS cannot assigm requested address." I have checked the Irq/IO setting in the hardware configuration agent and everything seems to be correct. To top it all off, once I logon if I enter "ifconfig elx0 192.168.1.2 up" then everything works fine. I tried to forceload the elx0 module in /etc/system to see if the module just wasn't loaded early enough but this did not help. Any ideas of what else I should check?
TIA -
Hi there,
I have developed an application to detect interrupts generated by a electronic card and act in consequence. The program has been developed in labview but it calls a dll; that was created with labwindows. The dll is programmed to open the visa communication, enable events and install the interrupt handler and when an interrupt is detected, it reads the value of the different registers of the card and returns it to labview to visualize them.
The problem is that when the program waits for an interrupt, a prompt appears with the message "Waiting for real-time target (RT PXI target) to respond" and the only option I have is to click on the button to disconnect from the pxi or just wait. If I wait and I generate an interrupt, the prompt disappears and the application visualize the data like it was expected.
To wait for the interrupt the following code has been programmed in the function:
while (flag == 0)
Sleep (1000);
When an interrupt occurs, the value of flag changes to 1 and the function continue without any problem. I am not really sure, but probably here is the problem and probably this is not the best way to wait for an interrupt because the sleep function suspends the thread for the configured time, but at least the computing load in the PXI is between 0% and 1%. I was wondering if somebody knows how to wait for an interrupt without "lost" the communication with the PXI and if there is a better way to do it.
Any answer will be welcome and thanks for them,
Jaime
Solved!
Go to Solution.Hello Naity,
First of all, in which thread runs the waiting process? Is it scheduled in another thread than the function setting the flag?
It scheduled in the same thread that I use to configure the communications and configure the card. Anyway, here is the pseudo code of the function interrupt that I programmed under labwindows,.
char* interrupt(void)
1. Open visa communications
2.Install handler interrupt --> status = viInstallHandler (instr, VI_EVENT_PXI_INTR, IntrHandler, VI_NULL); // the function IntrHandler will be called when an interrupt occurs
3. Enable event PXI interrupt
4. Wait
while (flag == 0)
Sleep (1000);
5. Visualize the data coming from the interrupt (registers and values measured with the card)
6. Uninstall handler interrupt
7. Close visa session
The interrupt handler function IntrHandler is called immediately when an interrupt occurs and the pseudo code is like this
ViStatus _VI_FUNCH IntrHandler(ViSession instr, ViEventType etype, ViEvent event, ViAddr userhandle)
1. Disable some functions of the card to avoid damages.
2. Read registers and put them in a buffer
3. Change the value of flag ---> flag = 1;
In labview, I call the function interrupt with a call library function node (see the capture attached) and the program reads and saves the data from returned from the function.
Secondly, I am not sure this method is the most elegant. You could for example register an event with the function and, insteand of setting a flag to 1, trigger the event and schedule it in another thread (if the function is thread safe). This could reduce your CPU Load even more and seem a bit cleaner to me.
I've never used events before in labwindows but I will try to do it in this way. But anyway, I suppose that I should; somehow, wait the event to occurs in labview while the waiting for the event is programmed inside the dll...and probably the same prompt that i am trying to avoid is going to appear again, because I am not returning the "control" to labview (I mean, labview executes the dll and waits for the event to occur. Then the execution of the labview program is stopped in the call library function node executing the dll)
Third point, which environment of development are you using?
I am working with LV 2010 sp1 and Labwindows cv 10.0.1 and with the real time module.
I did also another test, I divided the program in different functions, one to initialize the communication, another to wait until a interrupt has been detected and the other to obtain the data from the interrupt and close communications. With labview I call first with the call library function node the function to initialize, later I call inside a while loop the wait function like this
int waitAseconds (double seconds, short stop_waiting)
if(flag==1 || stop_waiting == 1)
flag = 1; //to detect the stop_waiting button
printf("flagAA =1 stop waiting = %d time = %d\n", stop_waiting, clock());
return flag;
else
SleepUS(seconds*1000000);
//a++;
printf("flag a= %d stop waiting = %d time = %d\n", flag, stop_waiting, clock());
return flag;
and when the program detects an interrupt, the function returns to labview the flag and stops the loop. Finally, it reads the values and close communications.
In this way, the prompt appears but after running the application for 10 or 20 minutes and also i checked that there is a time gap between the executions in the loop.
Thanks for your reply and your help,
Jaime
Attachments:
capture.png 40 KB -
My code runs on Java 5.
The callables I submit to a given ExecutorService are pure-computational, meaning: no calls to "low-level blocking methods".
I'd like these computations to be cancellable in a ASAP fashion: that means I'll sometimes call cancel(true) of the Future instance.
If I understand correctly, this will set the interruption status of the thread executing the given Future to true. Now my question is: how can my code distinguish between
a) an interruption request triggered by a cancel(true) on the Future
b) an interruption request triggered by a shutdownNow of the pool
I would like quick cancellation (through interruption), but quick and correct shutdown of the pool is important as well (meaning: I'll likely use shutdownNow() in some circumstances).
Reading stuff like the following make me kind of nervous:
http://forum.java.sun.com/thread.jspa?threadID=775640&start=20&tstart=0
I hope some of the fixes are sheduled for a backport to Java 5?My original question could have been more clear:
"Should I always propagate the interruption status from the Callable/Runnable to the executor?"
Looking some more at the TPE source, I guess the answer is:
"Not when running on Java 5.0, until the relevant fixes from 6.0 are backported"
So:
1) In my computational loop I inspect isInterrupted()
2) Upon interruption, I exit the loop
3) Before returning from run(), I clear the interruption status
If the current thread interruption status was set because of pool shutdown, the current worker thread will exit anyway (since getTask() will return null)
Message was edited by:
Pakka-Pakka -
consider the following program
class A extends Thread {
public void run() {
try {
synchronized (this) {
wait();
} catch (InterruptedException ie) {
System.out.println("isInterrupted() inside catch is " + isInterrupted());
public static void main(String[] args) {
A a1 = new A();
a1.start();
a1.interrupt();
System.out.println("a1.isInterrupted() inside main is " + a1.isInterrupted());
one of the output for this program is :
a1.isInterrupted() inside main is true
a1.isInterrupted() inside catch is false
why is this an output. As for the specification of thread method isInterrupted() method never resets the Interrupt flag of a thread.public static boolean interrupted()
Tests whether the current thread has been interrupted.
The interrupted status of the thread is cleared by this method.
In other words, if this method were to be called twice in succession,
the second call would return false
(unless the current thread were interrupted again,
after the first call had cleared its interrupted status
and before the second call had examined it).
*/ -
Hi,
I currently have an application that does in a seperate Thread receive udp packets in a loop around a Datagramsocket.receive(). Whenever a state change should occur, the thread is being interrupted by Thread.interrupt() in order to exit the DatagramSocket.receive().
That works nicely on the solaris version of the jvm (1.5.0-11) on x86 and sparc but it does not work on linux intel (i386 and amd64). There the receive simply ignores the interrupt.
What is the intended behavior ?
Do I have to move to timeOuts on each receive (which hinders fast state changes as timeouts have to occur and the loop has to be timeouted very often in order to be fast).
Little tests say: (java 1.5)
Linux 2.6.18 (32/64 Bit) : no interrupt
FreeBsd (32/64 Bit): interrupt works
Solaris 10 (sparc/64x86): interrupt works
MacOs 10.4: no interrupt
On Linux 2.6.18, java 1.4 - interrupt works.
At least a consistent behavior is missing!
J�rn
Here is the code:
SubThread.java:
package test;
import java.net.*;
import java.io.*;
public class SubThread extends Thread {
public DatagramSocket ds;
public boolean quit=false;
public SubThread() {
super();
try {
ds = new DatagramSocket();
} catch (Exception E) {
System.out.println("new DS failed: "+E.getMessage());
System.exit(-1);
public void run() {
byte[] buf = new byte[1000];
DatagramPacket p = new DatagramPacket(buf, buf.length);
System.out.println("Started subThread !");
while (!quit) {
try {
ds.setSoTimeout(10000); // 10 Seconds
ds.receive(p);
} catch (SocketTimeoutException E) {
System.out.println("ST: Hit timeout !");
} catch (InterruptedIOException E) {
System.out.println("ST: Interrupted IO Works !: "+E.getMessage());
quit=true;
} catch (Exception E) {
System.out.println("ST: Exception: "+E.getMessage());
System.out.println("Ended subThread !");
}Test.java:
package test;
public class Test {
static Integer a = 1;
public static void main(String[] args) {
SubThread st = new SubThread();
st.start();
try {
synchronized (a) {
System.out.println("Starting wait (1s) !");
a.wait(1000);
System.out.println("Sending interrupt()");
st.interrupt();
a.wait(1000);
if (!st.quit) {
System.out.println("As interrupts do not work, terminating by timeout !");
st.quit=true;
System.out.println("Waiting for end!");
} else
System.out.println("Ending !");
} catch (Exception E) {
System.out.println("Exception: "+E.getMessage());
}What is the intended behavior ?The intended behaviour is defined in http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()
' If this thread is blocked in an I/O operation upon an interruptible channel then the channel will be closed, the thread's interrupt status will be set, and the thread will receive a ClosedByInterruptException.'
DatagramSocket not being an InterruptibleChannel, this piece doesn't apply. None of the other pieces apply either, so the fallback applies:
' If none of the previous conditions hold then this thread's interrupt status will be set.'
If you're getting an interrupted read() on one platform, that's a bonus, but it's not the defined behaviour.
Use a DatagramSocket derived from DatagramChannel.open().socket() and it should work on all platforms. -
[votproductions@Arch ~]$ sudo uname -a
Linux Arch 3.3.7-1-ck #1 SMP PREEMPT Mon May 21 21:50:24 EDT 2012 x86_64 GNU/Linux
I think one of my disks are failing, /dev/sdb at ata4.0.
Here's an extract from dmesg:
[ 3210.426363] ata4: lost interrupt (Status 0x50)
[ 3210.426380] ata4.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
[ 3210.426384] ata4.00: failed command: READ DMA
[ 3210.426390] ata4.00: cmd c8/00:00:8f:ad:c9/00:00:00:00:00/e0 tag 0 dma 131072 in
[ 3210.426391] res 40/00:01:01:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
[ 3210.426394] ata4.00: status: { DRDY }
[ 3210.426402] ata4: soft resetting link
[ 3210.690275] ata4.00: configured for UDMA/33
[ 3210.690287] ata4: EH complete
Edit: Also displays READ DMA EXT and IDENTIFY DEVICE.
Here's smartctl for the drive:
smartctl 5.42 2011-10-20 r3458 [x86_64-linux-3.3.7-1-ck] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
=== START OF INFORMATION SECTION ===
Model Family: Seagate Barracuda 7200.9
Device Model: ST3160812AS
Serial Number: 5LS8BP3F
Firmware Version: 3.ADJ
User Capacity: 160,000,000,000 bytes [160 GB]
Sector Size: 512 bytes logical/physical
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Wed May 30 15:43:41 2012 IST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
See vendor-specific Attribute list for marginal Attributes.
General SMART Values:
Offline data collection status: (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 430) seconds.
Offline data collection
capabilities: (0x5b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.https://bbs.archlinux.org/viewtopic.php?id=142371
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 54) minutes.
SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 117 084 006 Pre-fail Always - 120025057
3 Spin_Up_Time 0x0003 099 093 000 Pre-fail Always - 0
4 Start_Stop_Count 0x0032 096 096 020 Old_age Always - 4490
5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 0
7 Seek_Error_Rate 0x000f 081 060 030 Pre-fail Always - 17677491374
9 Power_On_Hours 0x0032 085 085 000 Old_age Always - 13545
10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 096 096 020 Old_age Always - 4224
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
189 High_Fly_Writes 0x003a 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0022 058 039 045 Old_age Always In_the_past 42 (Min/Max 42/42)
194 Temperature_Celsius 0x0022 042 061 000 Old_age Always - 42 (0 14 0 0 0)
195 Hardware_ECC_Recovered 0x001a 109 045 000 Old_age Always - 42397154
197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0000 100 253 000 Old_age Offline - 0
202 Data_Address_Mark_Errs 0x0032 100 253 000 Old_age Always - 0
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 13536 -
# 2 Short offline Aborted by host 80% 13536 -
# 3 Extended offline Aborted by host 80% 7632 -
# 4 Short offline Completed without error 00% 0 -
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
So why does it matter?
Trying to access it via Dolphin ends up Dolphin being frozen. Trying to access it via Thunar says it's loading but it doesn't complete. Manual mount and fdisk -l simply stall. Finally, boot is spammed with those errors and it keeps checking for this drive and because of that, boot has increased to 10 minutes. But IMPORTANTLY, if I let the PC rest for a few minutes, the disk returns to normal for 5 minutes.
This is a NTFS device, so I checked it using chkdsk on Windows and VERY slowily (used to be 5 minutes, now I have to leave it for an hour), it completes and it says there are no errors.
The good news is that it's a backup device, so it doesn't contain any data that are important because they are all on my other sda1 disk, used also for the OS. However, I still would like this one fixed, because it suddenly just did that...
I also did change the cable connection, and that DID work for a while. The first time this happened, I replugged the SATA drive and it worked for a day. Second time it happened, I did the same and it worked for another day. But today, I did that, and it DIDN'T work. I even tried swapping cables from the main sda1 to this, nope, doesn't work.
If you are wondering why on earth am I running a SATA drive in IDE mode, it's because the BIOS only supports IDE mode and yet, detects SATA drives -_-.
Any thoughts?
Edit: Pacman stalls on checking for file conflicts too!
Last edited by VOT Productions (2012-05-30 20:52:29)The drive seems to be dying alright, I would do as MoonSwan recomends, get another drive that is larger than that one and do a full disk backup. Do use any reasonable means to keep the dying drive cool as it will probably give you a better chance of recovering all data.
Don't run any more tests on the drive as it will add more working hours to a drive that is already not too well, one extra pass of a test can be the difference between getting all data and having some data lost.
@cfr
The tests were probably issued manually and since short offline tests last for only a couple of minutes it is possible to have more than one test in the same hour.
As for getting "Aborted by host" status, I believe that it is not uncommon, at least for extended offline tests, but if I remember correctly I've never seen that for short offline tests. The reason why it happens is that you issue the test and then leave the drive alone, since there is no activity from the outside to the drive it may go to sleep, or something may put the drive to sleep, such as an usb/sata/ide controller bridge, in that case the test will be aborted and the status will be "Aborted by host".
I have seen this behavior with some of my external hard drives and I needed to put a script doing something on the drive every couple of minutes to keep it from going into standby so the extended offline test could be completed. -
How can I kill a thread.
I have read the many threads about killing a thread but they dont answer the question I need to know.
In class#1 I have the following snipet of code:
for (int i=0; i < docs.size(); i++)
try {
boolean blncompleted = false;
Map object = null;
OntologyCreatorThread ontThread = new OntologyCreatorThread ();
ontThread.start();
ontThread.join(15000); // Allow thread to process for up to 15 seconds.
// If thread is still running, kill the thread. I dont care about
// clean up since its only using memory and cpu, no DB is ever touched.
if (ontThread.getState().toString().equals("RUNNABLE")){
ontThread.interrupt();
ontThread.stop();
// set flag to false
blncompleted = false;
else {
// set flag to false and do a ton of other processing.
blncompleted = false;
object = ontThread.getObject();
catch (Exception Ex){
Ex.printStackTrace();
In my thread I have the following:
public class OntologyCreatorThread extends Thread {
Map object = null;
public OntologyCreatorThread(){
public void run() {
try {
// The line below takes forever to run sometimes.
object = functionCallToApi(stringOfText);
public Map getObject() {
return objects;
If the thread takes to long to run I just want to kill it.
I have tried interupt and stop and both dont work. Inside the run method of the thread I call an external API
which I pass a string of text. I can not get into that code because its from a Off the shelf product that we dont
have the code to. If the call in the run method takes to long I want to just kill this thread in the main class(#1).
No matter what I do I cant get the damn thing to stop.
The line below takes forever to run.
object = functionCallToApi(stringOfText);
Putting it in a while loop wont solve this problem because the processing is still taking place in the call to the api.
Thanks in advanceMessage was edited by:
Storm897Couple of things to consider:
1. Note that Thread.interrupted() and t.isInterrupted() are very different methods. The former clears the interrupted status so that a subsequent call will return false. The latter does not affect the interrupt status on the thread.
2. If your "atomic step one" catches an Exception, then you might be swallowing an InterruptedException. Basically the rule when a Thread is interrupted is that if it is in a blocking call, an InterruptedException is thrown. Otherwise, isInterrupted is set to true. So if you have blocking (I/O) calls in "atomic step one" and you're catching Exception, then it might be that the InterruptedException goes completely unnoticed.
3. If "atomic step one" takes a long time and you really want to abort the thread instantly, then you need some kind of method for doing so--you need to program in safe "stopping points". For example:
public class Helper implements Runnable {
private boolean _continue = true;
public void cancel() {
_continue = false;
public void run() {
_continue = true;
try {
// Do something until in safe/stable state
if(!_continue) return;
// Do something until in safe/stable state
if(!_continue) return;
while(_continue) {
// process single record in large data set
// Safe to stop at the end of each loop
if(!_continue) return;
// Do something else . . . etc.
} catch(InterruptedException ie) {
_continue = false; // Unnecessary, but here for illustration
}Casual programmers often don't care whether the thread stops safely or not, but it really is important especially if you are in the middle of some kind of transaction. That's why destroy(), cancel() et al are deprecated. -
HDD Problem - Freezes for a while during linux init
I've got a problem with my HDD. My Arch usually boots like thunderbolt, but since 3-4 days it freezes for a while before login screen. So I checked dmesg and this is what I found:
[ 53.360021] ata1: lost interrupt (Status 0x50)
[ 53.360041] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
[ 53.360045] ata1.00: failed command: WRITE DMA EXT
[ 53.360053] ata1.00: cmd 35/00:18:e0:d9:46/00:00:12:00:00/e0 tag 0 dma 12288 out
res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
[ 53.360056] ata1.00: status: { DRDY }
[ 53.360075] ata1: soft resetting link
[ 53.562494] ata1: nv_mode_filter: 0x3f39f&0x3f39f->0x3f39f, BIOS=0x3f000 (0xc6000000) ACPI=0x3f01f (20:900:0x11)
[ 53.628863] ata1.00: configured for UDMA/100
[ 53.628868] ata1.00: device reported invalid CHS sector 0
[ 53.628883] ata1: EH complete
[ 76.701622] fuse init (API version 7.21)
This is output from smartctl:
smartctl 6.1 2013-03-16 r3800 [i686-linux-3.9.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Seagate Barracuda 7200.10
Device Model: ST3500630A
Serial Number: 5QG1X3G1
Firmware Version: 3.AAE
User Capacity: 500,107,862,016 bytes [500 GB]
Sector Size: 512 bytes logical/physical
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA/ATAPI-7 (minor revision not indicated)
Local Time is: Fri Jun 7 11:41:09 2013 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 430) seconds.
Offline data collection
capabilities: (0x5b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 1) minutes.
Extended self-test routine
recommended polling time: ( 163) minutes.
SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 112 095 006 Pre-fail Always - 43863857
3 Spin_Up_Time 0x0003 094 092 000 Pre-fail Always - 0
4 Start_Stop_Count 0x0032 098 098 020 Old_age Always - 2833
5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 0
7 Seek_Error_Rate 0x000f 047 036 030 Pre-fail Always - 32856947045143
9 Power_On_Hours 0x0032 082 082 000 Old_age Always - 16160
10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 097 097 020 Old_age Always - 3563
187 Reported_Uncorrect 0x0032 016 016 000 Old_age Always - 84
189 High_Fly_Writes 0x003a 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0022 057 047 045 Old_age Always - 43 (Min/Max 23/43)
194 Temperature_Celsius 0x0022 043 053 000 Old_age Always - 43 (0 16 0 0 0)
195 Hardware_ECC_Recovered 0x001a 063 054 000 Old_age Always - 32213260
197 Current_Pending_Sector 0x0012 001 001 000 Old_age Always - 4294967295
198 Offline_Uncorrectable 0x0010 001 001 000 Old_age Offline - 4294967295
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0000 100 253 000 Old_age Offline - 0
202 Data_Address_Mark_Errs 0x0032 100 253 000 Old_age Always - 0
SMART Error Log Version: 1
ATA Error Count: 118 (device log contains only the most recent five errors)
CR = Command Register [HEX]
FR = Features Register [HEX]
SC = Sector Count Register [HEX]
SN = Sector Number Register [HEX]
CL = Cylinder Low Register [HEX]
CH = Cylinder High Register [HEX]
DH = Device/Head Register [HEX]
DC = Device Command Register [HEX]
ER = Error register [HEX]
ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.
Error 118 occurred at disk power-on lifetime: 15759 hours (656 days + 15 hours)
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
84 51 00 00 00 00 e0 Error: ICRC, ABRT at LBA = 0x00000000 = 0
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
25 20 01 00 00 00 e0 00 00:00:17.357 READ DMA EXT
c6 20 10 01 00 00 ef 00 00:00:17.357 SET MULTIPLE MODE
91 20 3f 01 00 00 ef 00 00:00:17.357 INITIALIZE DEVICE PARAMETERS [OBS-6]
10 20 01 01 00 00 e1 00 00:00:17.350 RECALIBRATE [OBS-4]
00 00 01 00 00 00 00 04 00:00:18.309 NOP [Abort queued commands]
Error 117 occurred at disk power-on lifetime: 15759 hours (656 days + 15 hours)
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
84 51 00 00 00 00 e0 Error: ICRC, ABRT at LBA = 0x00000000 = 0
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
25 20 01 00 00 00 e0 00 00:00:17.357 READ DMA EXT
c6 20 10 01 00 00 ef 00 00:00:17.357 SET MULTIPLE MODE
91 20 3f 01 00 00 ef 00 00:00:17.357 INITIALIZE DEVICE PARAMETERS [OBS-6]
10 20 01 01 00 00 e1 00 00:00:17.350 RECALIBRATE [OBS-4]
00 00 01 00 00 00 00 04 00:00:16.873 NOP [Abort queued commands]
Error 116 occurred at disk power-on lifetime: 15759 hours (656 days + 15 hours)
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
84 51 00 00 00 00 e0 Error: ICRC, ABRT at LBA = 0x00000000 = 0
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
25 20 01 00 00 00 e0 00 00:00:17.357 READ DMA EXT
c6 20 10 01 00 00 ef 00 00:00:17.357 SET MULTIPLE MODE
91 20 3f 01 00 00 ef 00 00:00:17.357 INITIALIZE DEVICE PARAMETERS [OBS-6]
10 20 01 01 00 00 e1 00 00:00:17.350 RECALIBRATE [OBS-4]
00 00 01 00 00 00 00 04 00:00:16.873 NOP [Abort queued commands]
Error 115 occurred at disk power-on lifetime: 15759 hours (656 days + 15 hours)
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
84 51 00 00 00 00 e0 Error: ICRC, ABRT at LBA = 0x00000000 = 0
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
25 20 01 00 00 00 e0 00 00:00:13.895 READ DMA EXT
c6 20 10 01 00 00 ef 00 00:00:13.895 SET MULTIPLE MODE
91 20 3f 01 00 00 ef 00 00:00:13.887 INITIALIZE DEVICE PARAMETERS [OBS-6]
10 20 01 01 00 00 e1 00 00:00:13.419 RECALIBRATE [OBS-4]
00 00 10 00 00 00 00 04 00:00:16.873 NOP [Abort queued commands]
Error 114 occurred at disk power-on lifetime: 15759 hours (656 days + 15 hours)
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
84 51 00 00 00 00 e0 Error: ICRC, ABRT at LBA = 0x00000000 = 0
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
25 20 01 00 00 00 e0 00 00:00:13.895 READ DMA EXT
c6 20 10 01 00 00 ef 00 00:00:13.895 SET MULTIPLE MODE
91 20 3f 01 00 00 ef 00 00:00:13.887 INITIALIZE DEVICE PARAMETERS [OBS-6]
10 20 01 01 00 00 e1 00 00:00:13.419 RECALIBRATE [OBS-4]
00 00 01 00 00 00 00 04 00:00:13.419 NOP [Abort queued commands]
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 16160 -
# 2 Short offline Completed without error 00% 15759 -
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
It would be great if someone could help me a little to prevent some major incident and point out what's happening. Thanks in advance!@pok0j
You best bet at getting the most uncorrupted data out of that disk, is to stop using it until you get a new disk that is at least twice as big as that one. The reason is that when you get a new disk, you want to try to do a full disk image in one go and get as much data out as possible before more data corruption occurs or the disk stops working at all.
The twice as large requirement is because you can then take your time to extract the files you want from the image and have enough free space to store them. After that make a backup strategy if you don't have one yet.
@drhill1
Has far as I know, both Current_Pending_Sector and Offline_Uncorrectable attributes start out at zero and 1) increase when there is a problem with a sector, 2) decrease when the problem is solved either by overwriting the affected sectors or when the sectors get reallocated thus decreasing the count, which should return to zero when there are no more sectors with problems. This implies that the count should never exceed the total number of user addressable sectors. Like I said, I have never seen any disk where those attributes didn't make sense, if those attributes weren't defined they wouldn't be reported I suppose. -
[SOLVED] SSD and boot problem
I recently bought a new 30GB Corsair SSD, and it runs wonderfully. However, the device takes a considerably long time to initialize on boot (~30-45 seconds).
Here's a snippet of the relevant dmesg output:
[ 23.360042] ata5: lost interrupt (Status 0x58)
[ 23.363366] ata5: drained 65536 bytes to clear DRQ
[ 23.447633] ata5.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
[ 23.447673] scsi 4:0:0:0: CDB: cdb[0]=0x12: 12 00 00 00 60 00
[ 23.447683] ata5.00: cmd a0/01:00:00:60:00/00:00:00:00:00/a0 tag 0 dma 96 in
[ 23.447684] res 40/00:02:00:24:00/00:00:00:00:00/a0 Emask 0x4 (timeout)
[ 23.447754] ata5.00: status: { DRDY }
[ 23.447810] ata5: soft resetting link
[ 23.653843] ata5.00: configured for UDMA/33
[ 23.654431] ata5: EH complete
[ 23.654435] scsi scan: 96 byte inquiry failed. Consider BLIST_INQUIRY_36 for this device
[ 23.657130] scsi 4:0:0:0: CD-ROM TOSHIBA DVD-ROM SD-R1312 1011 PQ: 0 ANSI: 5
[ 54.373360] ata5: lost interrupt (Status 0x58)
[ 54.376674] ata5: drained 65536 bytes to clear DRQ
[ 54.465937] ata5.00: limiting speed to UDMA/25:PIO4
[ 54.465941] ata5.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
[ 54.465985] sr 4:0:0:0: CDB: cdb[0]=0x5a: 5a 00 2a 00 00 00 00 00 80 00
[ 54.465996] ata5.00: cmd a0/01:00:00:80:00/00:00:00:00:00/a0 tag 0 dma 16512 in
[ 54.465997] res 40/00:03:00:00:00/00:00:00:00:00/a0 Emask 0x4 (timeout)
[ 54.466085] ata5.00: status: { DRDY }
[ 54.466144] ata5: soft resetting link
I haven't encountered this problem with any other drive I've put in there, so I'm guessing it must be SSD-related. Has anyone else experienced something similar, and could you point me in the right direction? Thanks.
Last edited by itsbrad212 (2012-04-01 00:05:28)itsbrad212 wrote:
falconindy wrote:Consider RMA'ing the drive.
Do you think it's defective/worth replacing? It's more of an annoyance than anything, and the drive has no other visible issues other than on initialization.
Yes, I do. Healthy drives don't timeout on simple DMA initialization requests.
Maybe you are looking for
-
I have a Mac mini (Mid 2011). It has become slow in some ways even though I have 8 GB 1333 MHz DDR3 memory and almost 250GB of free storage. I recently installed Yosemite 10.10.1 (14B25) but I had noticed the slow down prior to that. Notably, videos
-
Hello everyone! I have a NS42P650A11 television (42" Insignia 720p). Anyway, my roommates and I regularly enjoy playing FIFA 11 on our Xbox 360 which we have hook into input 2. We've always played in HD and it's been a great picture. However, last n
-
Is there any way to upgrade iphone5 to 5s in india
is there any way to upgrade iphone5 to iphone5s in india
-
PO output for delivery cost vendor
Hi All Is it possible to provide purchase order output for the delivery costs to the delivery vendor.
-
I had to reinstall my osx (Leopard, updated to 10.5.8), uninstalled all iwork 09 files, then reinstalled the software from the DVD and all updates. It still won't work. This is the error log sent to apple Process: Pages [228] Path: