Last active
January 1, 2023 17:46
-
-
Save WebGE/f24c17bb13f10b38eaf21725451e3754 to your computer and use it in GitHub Desktop.
MicroLED - Illustration de l'interblocage
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
import threading | |
import logging | |
VERROU_LED={} | |
VERROU_LED['A']=threading.Lock() | |
VERROU_LED['B']=threading.Lock() | |
VERROU_LED['C']=threading.Lock() | |
def acquerirLED(led): | |
VERROU_LED[led].acquire() | |
def rendreLED(led): | |
VERROU_LED[led].release() | |
def prog(numproc,ledprim,ledsec,couleur): | |
while True: | |
# A compléter | |
logging.info(f"Led{ledprim}={couleur} par P{numproc}") | |
# A compléter | |
logging.info(f"Led{ledsec}={couleur} par P{numproc}") | |
# A compléter | |
# Programme principal | |
format = "%(asctime)s: %(message)s" | |
logging.basicConfig(format=format, level=logging.INFO, | |
datefmt="%H:%M:%S", encoding='utf-8') | |
p1 = threading.Thread(target=prog, args=[1,'A','B','vert']) | |
p2 = threading.Thread(target=prog, args=[])# A compléter | |
p3 = threading.Thread(target=prog, args=[])# A compléter | |
p1.start() | |
# A compléter | |
# A compléter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment