Skip to content

Commit

Permalink
Merge pull request #5 from djordje200179/master
Browse files Browse the repository at this point in the history
Ispravke nekih zadataka
  • Loading branch information
KockaAdmiralac authored Dec 10, 2022
2 parents e9c75b0 + 8020bb3 commit a8d925c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion os2/2013/10/k1-sol.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ monitor Mutex;
var isLocked : boolean,
isFree : condition;
procedure wait ()
procedure lock ()
begin
if isLocked then isFree.wait();
isLocked:=true;
Expand Down
3 changes: 2 additions & 1 deletion os2/2017/12/k1-sol.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,15 @@ public class RequestHandler extends Thread {
throws InterruptedException {
synchronized (filesInUse) {
while (filesInUse.contains(fileName)) {
wait();
filesInUse.wait();
}
filesInUse.add(fileName);
}
}
private void finishWithFile(String fileName) {
synchronized (filesInUse) {
filesInUse.remove(fileName);
filesInUse.notifyAll();
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions os2/2019/11/k1-sol.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,18 @@ public class RequestHandler extends Thread {
public void run() {
Service service = new Service(client);
while(true) {
// #<method>#arg0#...#[0]#[1]#...#[n - 1]#
// <method>#arg0#...#[0]#[1]#...#[n - 1]
String[] args = service.receiveMessage().split("#");
if (args[0].equals("lock")) {
lock(args);
service.sendMessage("OK");
} else if (args[0].equals("lock")) {
} else if (args[0].equals("unlock")) {
unlock(args);
service.sendMessage("OK");
} else if (args[0].equals("lock")) {
} else if (args[0].equals("write")) {
write(args);
service.sendMessage("OK");
} else if (args[0].equals("lock")) {
} else if (args[0].equals("read")) {
service.sendMessage(read(args));
}
}
Expand Down
2 changes: 1 addition & 1 deletion os2/2021/11/k1.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private:
};
class BoundedBuffer {
public:
BoundedBuffer() : numberInBuffer(0) {}
BoundedBuffer() : numberInBuffer(0), slotAvailable(&mutex), itemAvailable(&mutex) {}
void put(Data* d);
Data* get();
private:
Expand Down

0 comments on commit a8d925c

Please sign in to comment.