Commit 45a8d284 authored by Patrick Mochel's avatar Patrick Mochel

[power] Fix up refrigerator to work with ^Z-ed processes

Originally from Pavel Machek: 

schedule() added makes processes start at exactly that point, making
printouts nicer.
parent 8cf4ddc3
...@@ -23,14 +23,16 @@ ...@@ -23,14 +23,16 @@
*/ */
#define TIMEOUT (6 * HZ) #define TIMEOUT (6 * HZ)
#define INTERESTING(p) \
/* We don't want to touch kernel_threads..*/ \ static inline int freezeable(struct task_struct * p)
if (p->flags & PF_IOTHREAD) \ {
continue; \ if ((p == current) ||
if (p == current) \ (p->flags & PF_IOTHREAD) ||
continue; \ (p->state == TASK_ZOMBIE) ||
if (p->state == TASK_ZOMBIE) \ (p->state == TASK_DEAD))
continue; return 0;
return 1;
}
/* Refrigerator is place where frozen processes are stored :-). */ /* Refrigerator is place where frozen processes are stored :-). */
void refrigerator(unsigned long flag) void refrigerator(unsigned long flag)
...@@ -71,8 +73,10 @@ int freeze_processes(void) ...@@ -71,8 +73,10 @@ int freeze_processes(void)
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
do_each_thread(g, p) { do_each_thread(g, p) {
unsigned long flags; unsigned long flags;
INTERESTING(p); if (!freezeable(p))
if (p->flags & PF_FROZEN) continue;
if ((p->flags & PF_FROZEN) ||
(p->state == TASK_STOPPED))
continue; continue;
/* FIXME: smp problem here: we may not access other process' flags /* FIXME: smp problem here: we may not access other process' flags
...@@ -104,15 +108,18 @@ void thaw_processes(void) ...@@ -104,15 +108,18 @@ void thaw_processes(void)
printk( "Restarting tasks..." ); printk( "Restarting tasks..." );
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
do_each_thread(g, p) { do_each_thread(g, p) {
INTERESTING(p); if (!freezeable(p))
continue;
if (p->flags & PF_FROZEN) p->flags &= ~PF_FROZEN; if (p->flags & PF_FROZEN) {
else p->flags &= ~PF_FROZEN;
wake_up_process(p);
} else
printk(KERN_INFO " Strange, %s not stopped\n", p->comm ); printk(KERN_INFO " Strange, %s not stopped\n", p->comm );
wake_up_process(p); wake_up_process(p);
} while_each_thread(g, p); } while_each_thread(g, p);
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
schedule();
printk( " done\n" ); printk( " done\n" );
MDELAY(500); MDELAY(500);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment