12.07.2015 Views

Spis treœci - Patrz

Spis treœci - Patrz

Spis treœci - Patrz

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

end; {ZWALNIAM}beginprzy_stole := Oend; {KELNER}4.4.10 Zasoby dwóch typówProcedura przydziału musi mieć parametr wejściowy określający, do której grupy należyproces zgłaszający żądanie. Procedura ta musi zwracać typ przydzielonego zasobom (ważnedla procesów grupy drugiej i trzeciej) oraz informację, czy zasób przydzielono (ważne dlaprocesów grupy trzeciej).monitor ZASOBY;const M = ?;N = ?;var wolneA, wolneB:. integer;KOLEJKA1, KOLEJKA2: condition;export procedure PRZYDZIEL(grupa: 1..3; var typ: A..B; var dostał: boolean);begincase grupa ofl: beginif wolneA = O then wait(KOLEJKAl);wolneA := wolneA - lend;2: beginif (wolneA = 0) and (wolneB = 0) thenwait(KOLEJKA2);if wolneA > O then beginwolneA := wolneA - 1;typ := Aend elseif wolneB > O then beginwolneB := wolneB - 1;typ := Bendend;3: if wolneB > O then beginwolneB := wolneB - 1;dostał := trueend elseif wolneA > O then beginwolneA := wolneA - 1;dostał := trueend else dostał := falseendend; {PRZYDZIEL}export procedure ZWOLNIJ(typ: A..B);begincase typ ofA: beginwolneA := wolneA + 1;if not empty(KOLEJKAl) then signal(KOLEJKAl)else signal(KOLEJKA2)93

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!