Philipp Rumpf writes:
> On Sun, Jun 25, 2000 at 01:30:50AM +1000, Andrew Morton wrote:
> > +static volatile int ice_block;
> > +static spinlock_t freeze_lock = SPIN_LOCK_UNLOCKED;
> > +
> > +static int
> > +antarctica(void *dummy)
> > +{
> > + printk("start antarctica on %d\n", smp_processor_id());
> > + while (ice_block)
> > + ;
> > + printk("stop antarctica on %d\n", smp_processor_id());
> > + return 0;
> > +}
> > +
> > +static int
> > +freeze_other_cpus(void)
> > +{
> > + int cpu, retval;
> > +
> > + if (!spin_trylock(&freeze_lock))
> > + return -EAGAIN;
> > +
> > + printk("start freeze_other_cpus()\n");
> > + ice_block = 1;
> > + for (cpu = 0; cpu < smp_num_cpus - 1; cpu++) {
> > + retval = kernel_thread(antarctica, (void *)0, 0);
> > + if (retval < 0)
> > + goto out_melt;
> > + }
> > + printk("continue freeze_other_cpus()\n");
> > + return 0;
> > +out_melt:
> > + ice_block = 0;
> > + spin_unlock(&freeze_lock);
> > + return retval;
> > +}
>
> You don't guarantee all the other kernel_threads have started executing.
>
> Basically you need either an atomic_inc or a per-CPU flag somewhere.
Or why not use smp_call_function()? Just move it from the i386 tree to
the generic tree.
Regards,
Richard....
Permanent: rgooch@xxxxxxxxxxxxx
Current: rgooch@xxxxxxxxxxxxxxx
|