I am new in the forum and in programming in general.At the moment i study "Operation Systems" and Java. This week we started the topic "Semaphores" and it seems to me that it's a bit confusing. I have this exercise:
shared variable  numberofworks = 0 
    EmployeeA 
    {
        while (True) {
            A_works_outside();
            A_works_inside();
            numberofworks =numberofworks + 1;
        }
    }
    EmployeeB
    {
        while (True) {
            B_works_outside();
            B_works_inside();
            numberofworks =numberofworks + 1;
        }
    }
well,the exercise wants to use semaphores (P and V) so
- In i repetition of EmployeeA the A_works_inside()runs only when B_works_outside() is finished
- In i repetition of EmployeeB the - Β_works_inside()runs only when Α_works_outside() is finished
- Variable - numberofworksmust be the sum of- numberofworksA + numberofworksB
I must write the code in Java and in "operation system" before helping me in this exercise (if you can of course) General questions in semaphores: What's the basic difference between mutex and a sempahore? and how should i understand when to use mutex or not?
