Skip to contentSkip to conversation

stop threads failed!

DISCUSSION Hua Feijun 2 participants 3 messages Dec 17, 2005 – Dec 19, 2005 1 message not in the archive

lore
Share & tools
lore

Hua Feijun

author
#0 lore raw

I want to set threads's status to TASK_STOPPED by the following code.The syslog has show this rourine has been executed,buf the thread is still running.Who can tell me the reason?Thanks very much! write_lock(&tasklist_lock);
do
{
printk("set threads stopped\n");
p->state = TASK_STOPPED;
} while ((p = next_thread(p)) != leader); write_unlock(&tasklist_lock);
schedule();

#1 lore raw
Quoted 4 lines · Hua Feijun

I want to set threads's status to TASK_STOPPED by the following code.The syslog has show this rourine has been executed,buf the thread is still running.Who can tell me the reason?Thanks very much! write_lock(&tasklist_lock);

Quoted 8 lines

do
{
printk("set threads stopped\n");
p->state = TASK_STOPPED;
} while ((p = next_thread(p)) != leader);
write_unlock(&tasklist_lock);
schedule();
-

Have you specified the state TASK_INTERRUPTIBLE when you wake up the thread? If not then do it to ba able to stop it later. Anybody else correct me if I am wrong please
Regards
Nauman

Quoted 5 lines

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 3 lines · Hua Feijun

Sorry, I couldn't describe the problem clearly.I means these threads did not go to sleep'in fact, they didn't stop runing.

Kindly also CC this to linux-kernel as well so that you have more chances to get the solution of your problem.
It seems to me that you may have missed SIG_PENDING at the time when you setup your thread. You will have to signal your thread to kill it. Just setting up TASK STATE is not enough untill the process gets scheduled or it gets the signal to kill itself explicitly

Quoted 18 lines

2005/12/18, Nauman Tahir <[email protected]>:

Quoted 17 lines · Hua Feijun
Quoted 4 lines

I want to set threads's status to TASK_STOPPED by the following code.The syslog has show this rourine has been executed,buf the thread is still running.Who can tell me the reason?Thanks very much! write_lock(&tasklist_lock);

Quoted 8 lines

do
{
printk("set threads stopped\n");
p->state = TASK_STOPPED;
} while ((p = next_thread(p)) != leader);
write_unlock(&tasklist_lock);
schedule();
-

Have you specified the state TASK_INTERRUPTIBLE when you wake up the thread? If not then do it to ba able to stop it later. Anybody else correct me if I am wrong please