Garbage collection code
Hi folks,
Can someone tell me what is happening in this code copied below
Specifically what does schedule at the end of the code does.
Also kindly tell me a link where I can read abt these things in detail.
With regards
Vikram
for (;;) {
spin_lock_irq(¤t->sigmask_lock);
siginitsetinv (¤t->blocked, sigmask(SIGHUP) | sigmask(SIGKILL) |
sigmask(SIGSTOP) | sigmask(SIGCONT));
recalc_sigpending(current); spin_unlock_irq(¤t->sigmask_lock);
if (!thread_should_wake(c)) {
set_current_state (TASK_INTERRUPTIBLE); D1(printk(KERN_EMERG "jffs2_garbage_collect_thread sleeping. ..\n")); /* Yes, there's a race here; we checked thread_should_wake() before
setting current->state to TASK_INTERRUPTIBLE. But it doesn't matter - We don't care if we miss a wakeup, because the GC thread is only an optimisation anyway. */
schedule();
}
Quoted 6 lines · Vikram Mehta
Can someone tell me what is happening in this code copied below
Specifically what does schedule at the end of the code does.
Also kindly tell me a link where I can read abt these things in detail.
Look for the documentation to BSD's lfs (log-structured file system), jffs2 uses the same basic principle. There is also a jffs2 specific paper somewhere on redhat's site, google is your friend.
Quoted 6 lines
for (;;) {
spin_lock_irq(¤t->sigmask_lock);
siginitsetinv (¤t->blocked, sigmask(SIGHUP) | sigmask(SIGKILL) |
sigmask(SIGSTOP) | sigmask(SIGCONT));
recalc_sigpending(current);spin_unlock_irq(¤t->sigmask_lock);
Allow SIGHUP, SIGKILL, SIGSTOP and SIGCONT to reach the gc thread. (so people can wake us up)
Quoted 1 line
if (!thread_should_wake(c)) {No work to do right now.
Quoted 7 lines
set_current_state (TASK_INTERRUPTIBLE);
D1(printk(KERN_EMERG "jffs2_garbage_collect_thread sleeping. ..\n"));
/* Yes, there's a race here; we checked thread_should_wake() before
setting current->state to TASK_INTERRUPTIBLE. But it doesn't
matter - We don't care if we miss a wakeup, because the GC thread
is only an optimisation anyway. */
schedule();Go to sleep.
Quoted 1 line
}
Jörn
Signature · 4 lines
ticks = jiffies; while (ticks == jiffies); ticks = jiffies; -- /usr/src/linux/init/main.c