lkml.org 
[lkml]   [2002]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] 2.5.21 Nonlinear CPU support
From
Date
On Wed, 2002-06-12 at 13:03, H. Peter Anvin wrote:

> while ( 1 ) {
> disable_preemption();
> cpu = current_cpu();
> if ( decompression_buffers[cpu] ) {
> do_decompression(decompression_buffers[cpu]);
> enable_preemption();
> break; /* DONE, EXIT LOOP */
> } else {
> enable_preemption();
> down_sem(allocation_semaphore);
> /* Avoid race condition here */
> if ( !decompression_buffers[cpu] )
> decompression_buffers[cpu] = vmalloc(BUFFER_SIZE);
> up_sem(allocation_semaphore);
> }
> }

Just a note, in 2.5 we recently added put_cpu() and get_cpu() that work
basically like:

int cpu;

cpu = get_cpu();
/* critical non-preemptible section */
put_cpu();
i.e., a preempt-safe interface to smp_processor_id() that disables and
enables preemption for you... makes it a little easier.

Robert Love

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

\
 
 \ /
  Last update: 2005-03-22 13:26    [W:0.199 / U:0.540 seconds]
©2003-2011 Jasper Spaans. Advertise on this site