Skip to contentSkip to conversation

FUSYN and RT

DISCUSSION Daniel Walker 3 participants 5 messages Apr 12, 2005 – Apr 13, 2005

lore
Share & tools
lore
#0 lore raw

I just wanted to discuss the problem a little more. From all the conversations that I've had it seem that everyone is worried about having PI in Fusyn, and PI in the RT mutex.

It seems like these two locks are going to interact on a very limited basis. Fusyn will be the user space mutex, and the RT mutex is only in the kernel. You can't lock an RT mutex and hold it, then lock a Fusyn mutex (anyone disagree?). That is assuming Fusyn stays in user space.

The RT mutex will never lower a tasks priority lower than the priority given to it by locking a Fusyn lock.

At least, both mutexes will need to use the same API to raise and lower priorities.

The next question is deadlocks. Because one mutex is only in the kernel, and the other is only in user space, it seems that deadlocks will only occur when a process holds locks that are all the same type.

Daniel

#1 lore raw
Quoted 4 lines · Daniel Walker

It seems like these two locks are going to interact on a very limited basis. Fusyn will be the user space mutex, and the RT mutex is only in the kernel. You can't lock an RT mutex and hold it, then lock a Fusyn mutex (anyone disagree?). That is assuming Fusyn stays in user space.

Well yeah, but you could lock a fusyn, then invoke a system call which locks a kernel semaphore.

Regards,
Joe
--
"Money can buy bandwidth, but latency is forever" -- John Mashey

#2 lore raw
Quoted 9 lines · Joe Korty
Quoted 4 lines · Daniel Walker

It seems like these two locks are going to interact on a very limited basis. Fusyn will be the user space mutex, and the RT mutex is only in the kernel. You can't lock an RT mutex and hold it, then lock a Fusyn mutex (anyone disagree?). That is assuming Fusyn stays in user space.

Well yeah, but you could lock a fusyn, then invoke a system call which locks a kernel semaphore.

Right .. For deadlock detection, I want to assume that the fusyn lock is on the outer level. That way both deadlock detection system will work properly (in theory).

Daniel

#3 lore raw
In reply to Daniel Walker
Quoted 5 lines · Daniel Walker

I just wanted to discuss the problem a little more. From all the conversations that I've had it seem that everyone is worried about having PI in Fusyn, and PI in the RT mutex.

Quoted 7 lines

It seems like these two locks are going to interact on a very limited basis. Fusyn will be the user space mutex, and the RT mutex is only in the kernel. You can't lock an RT mutex and hold it, then lock a Fusyn mutex (anyone disagree?). That is assuming Fusyn stays in user space.

The RT mutex will never lower a tasks priority lower than the priority given to it by locking a Fusyn lock.

I have not seen the Fusyn code. Where is the before-any-lock priority stored? Ingo's code sets the prio back to what is given by static_prio. So, if Fusyn sets static_prio it will work as you say. It it will then be up to Fusyn to restore static_prio to what it was before the first Fusyn lock.

Quoted 3 lines

At least, both mutexes will need to use the same API to raise and lower priorities.

You basicly need 3 priorities:
1) Actual: task->prio
2) Base prio with no RT locks taken: task->static_prio
3) Base prio with no Fusyn locks taken: task->??

So no, you will not need the same API, at all :-) Fusyn manipulates task->static_prio and only task->prio when no RT lock is taken. When the first RT-lock is taken/released it manipulates task->prio only. A release of a Fusyn will manipulate task->static_prio as well as task->prio.

Quoted 4 lines

The next question is deadlocks. Because one mutex is only in the kernel, and the other is only in user space, it seems that deadlocks will only occur when a process holds locks that are all the same type.

Yes.
All these things assumes a clear lock nesting: Fusyns are on the outer level, RT locks on the inner level. What happens if there is a bug in RT locking code will be unclear. On the other hand errors in Fusyn locking (user space) should not give problems in the kernel.

Quoted 4 lines

Daniel

I think that it might be a fast track to get things done to have a double PI-locking system, one for the kernel and one for userspace. But I think it is is bad maintainance to have to maintain two seperate systems. The best way ought to be to try to only have one PI system. The kernel is big and confusing enough as it is!

Esben

#4 lore raw
Quoted 9 lines · Esben Nielsen

You basicly need 3 priorities:
1) Actual: task->prio
2) Base prio with no RT locks taken: task->static_prio
3) Base prio with no Fusyn locks taken: task->??

So no, you will not need the same API, at all :-) Fusyn manipulates task->static_prio and only task->prio when no RT lock is taken. When the first RT-lock is taken/released it manipulates task->prio only. A release of a Fusyn will manipulate task->static_prio as well as task->prio.

mutex_setprio() , I don't know if you could call that an API but that's what I was talking about.. They should both use that. I think it would be better if the RT mutex (and fusyn) didn't depend on a field in the task_struct to retain the old priority. That would make it easier ..

This goes back to the assumption that the locking isn't intermingled once you get into the kernel . The RT mutex can safely save the owner priority with out a Fusyn jumping in and changing it and the other way around..

Daniel