views:

45

answers:

1

Hello

From the http://lkml.indiana.edu/hypermail/linux/kernel/0103.1/0030.html I learn about a new type of mutexes in linux, an adaptive_np one:

The PTHRED_MUTEX_ADAPTIVE_NP is a new mutex that is intended for high throughput at the sacrifice of fairness and even CPU cycles. This mutex does not transfer ownership to a waiting thread, but rather allows for competition. Also, over an SMP kernel, the lock operation uses spinning to retry the lock to avoid the cost of immediate descheduling.

There is mentioned "Cost of immediate descheduling". How much is this cost? (In terms of cpu ticks; TLB, TSS, smth else reloading) What is done in kernel between an "immediate descheduling request" and rescheduling back to the run state again?

How can I do a explicit descheduling and how can I measure its cost?

+2  A: 

It looks like it's just a lightweight interlock intended to allow threads to avoid the scheduler.

The idea is to replace a relatively heavy context-switch-based operation with a hopefully-short period of time spent in a spinlock.

Disregard the use of "new", spinlocks are as old as the hills. It was, I guess, new to that pthread library almost 10 years ago.

An "explicit descheduling" is presumably the same thing as a context switch, so you could measure this by having two threads yield() the CPU to each other a million times and measure the runtime.

DigitalRoss
From what I understand, its more 'be ignored while getting serviced' than 'avoid'. The priority of the parent (AFAIK) still plays into it.Its supposed to be the answer to futex hell on large SMP machines. Let the kernel arbitrate without actually arbitrating, or something to that effect.In any event, +1 for articulating it simply.
Tim Post
How heavy is context-switch? How heavy are rescheduler computatuions?As i think, yield() will not immediately start other thread, but will wait for "sched tick", 1s / HZ = 1 millisecond
osgx