Garbage collection code

Jörn Engel joern at wohnheim.fh-wedel.de
Mon Jul 21 05:44:06 EDT 2003


On Mon, 21 July 2003 12:28:30 -0700, Vikram Mehta wrote:
> 
> 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.

> for (;;) {
>   spin_lock_irq(&current->sigmask_lock);
>   siginitsetinv (&current->blocked, sigmask(SIGHUP) | sigmask(SIGKILL) |
> sigmask(SIGSTOP) | sigmask(SIGCONT));
>   recalc_sigpending(current);
>   spin_unlock_irq(&current->sigmask_lock);

Allow SIGHUP, SIGKILL, SIGSTOP and SIGCONT to reach the gc thread.
(so people can wake us up)

>   if (!thread_should_wake(c)) {

No work to do right now.

>                         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.

> }

Jörn

-- 
ticks = jiffies;
while (ticks == jiffies);
ticks = jiffies;
-- /usr/src/linux/init/main.c



More information about the linux-mtd mailing list