On 2019-12-11 14:35, Gregory Nutt wrote:
>
>> the kernel big lock is a direct and effiective way to protocted the
>> share resources between cpus, but has weaks on performace.
>> the mult-level fin grained lock is more effenciency but hard to
>> mantaince and need more skills and experience.
>> so which way did the present nutttx adopted?
>
> I am not so sure that this terminology makes sense within NuttX.
> Inter-CPU locks are implemented as simple spinlocks. There are many,
> many spinlocks so I think this makes them fine grained.
Inter-cpu locks are pretty much always some kind of spin-lock. There are
not really that many other ways of doing it...
> The is an internal OS interface to enter a critical section. On a
> single CPU, it just disables interrupts. In the SMP case, it disables
> local interrupts and takes a spinlock.
I think the central question here then is if there are individual
spinlocks for different critical sections, or just one. The fact that
there is just a disabling of interrupts in the single CPU case might
suggest that there is just one spinlock, but it's not necessarily so...
And since each semaphore (below) seems to have its own spin-lock, that
would suggest that maybe the locking is fine-grained.
> Each semaphore also has a spinlock. In order to take the semaphore, you
> need to hold a spinlock. There are, of course, many many instances of
> semaphores, hence, I would think they classify as "fine-grained". All
> higher level locking is performed on top of semaphores so the
> spin-locking comes with the semaphores.
Yes, that I would definitely then call find-grained.
But the terminology is mostly just applied to critical sections in the
kernel, where various data structures are modified that all CPUs might
be interested in.
Johnny
--
Johnny Billquist || "I'm on a bus
|| on a psychedelic trip
email:
b...@softjar.se || Reading murder books
pdp is alive! || tryin' to stay hip" - B. Idol