I'd say no, the current method is not okay.
Specifically, say a type 0 comes in, and gets through enter. type 1 then comes through before type 0 exited. It hits the mutex, finds that the process type is wrong and locks on m1. Type 0 then comes through, unlocks m, resets process type, and the lock on m1 is still in effect.
In addition, if you have 2 processes of type 0 enter, the first one to exit will cause the running process type to be reset while processes are still in the critical section.
I'm making an assumption that 'up' is akin to unlock, and 'down' is akin to lock; it sounds like a set of methods intended for a semaphore though. I'm also making an assumption that there are only two mutexes for the system (m and m1); as the markup isn't perfectly clear about that.
EDIT: The suggestion you offered would come out to something like this:
shared: this.type = -1;
mutex m, m1=1;
count=0;
enter{
down(m)
if (this.type == process.type) up(m1)
down(m1)
this.type= process.type
count++;
up(m)
}
exit {
count--;
if(count==0) this.type = -1
up(m1)
}
This still has the problem that exit isn't thread safe on state modifications; and that when a new Process is woken/starts executing, its brethren are not woken.
I'm not entirely certain that there is a safe way to do this without Condition variables; unless there is more information about the problem available. (ie is this in the context of a 'Monitor', where method executions are already threadsafe)