-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…an i implementiran u sve operacije os-a mutex kljuc koji pokriva sve kriticne zone
- Loading branch information
1 parent
d77a159
commit 52b2807
Showing
5 changed files
with
51 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from operatingSystem import OS | ||
from cpu import CPU | ||
from algorithmPlanner import * | ||
import threading | ||
import threading | ||
|
||
class System: | ||
_instance = None | ||
|
||
def __new__(cnt): | ||
if not cnt._instance: | ||
cnt._instance = super().__new__(cnt) | ||
return cnt._instance | ||
|
||
def __init__(self, n = 1): | ||
self.mutex = threading.Lock() | ||
self.cpu = [CPU() for _ in range(5)] | ||
self.os = OS(FirstComeFirstServe()) | ||
|
||
for i in range(n): | ||
self.cpu[i].setOS(self.os) | ||
t = threading.Thread(target=self.cpu[i].run) | ||
self.threads.append(t) | ||
|
||
def startThreads(self): | ||
for thread in self.threads: | ||
thread.start() | ||
|
||
self.joinThreads() | ||
|
||
def joinThreads(self): | ||
for thread in self.threads: | ||
thread.join() | ||
|
||
|