a first scheme
This commit is contained in:
parent
aeefc0dd03
commit
ced030fc22
|
@ -1,3 +1,36 @@
|
|||
import threading
|
||||
from datetime import timedelta
|
||||
from datetime import datetime
|
||||
import random
|
||||
import time
|
||||
|
||||
def local_worker(coord, id):
|
||||
start = datetime.now().timestamp()
|
||||
val = random.randint(1,1000)
|
||||
time.sleep(val / 1000)
|
||||
prev = space[coord]
|
||||
next = space[coord] = 10 + val % 89
|
||||
print('{} on [{}] : {} > {} by local thread n°{:>3} {!s:.4}'.format(
|
||||
space,
|
||||
coord,
|
||||
prev,
|
||||
next,
|
||||
str(id),
|
||||
datetime.now().timestamp() - start
|
||||
)
|
||||
)
|
||||
|
||||
from threading import Thread
|
||||
space = []
|
||||
for i in range(0,10):
|
||||
space.append(random.randint(10,99))
|
||||
print(space,' < initialglobal state')
|
||||
for k in range (1,20):
|
||||
t = Thread(target=local_worker, args=(random.randint(0,len(space) - 1), k))
|
||||
t.start()
|
||||
|
||||
|
||||
"""
|
||||
Le **scheduler**, ou processus principal, effectue un calcul sur l'**état global**.
|
||||
Pour cela, il génère des threads de calcul locaux ou '**local_workers**'
|
||||
auxquels il confie une partie de l'état global.
|
||||
|
@ -27,3 +60,5 @@ Il délègue à la **CLI** les fonctions de communications avec les modules pér
|
|||
|
||||
3. mesures / recueil des commandes / retour d'information
|
||||
|
||||
"""
|
||||
|
||||
|
|
Loading…
Reference in New Issue