





















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of concurrent programming paradigms, including shared memory and message passing models, as well as an introduction to socket programming in python. It covers the basics of socket creation, client-server communication, and the methods and functions used in socket programming. The document also discusses common issues in concurrent programming, such as race conditions, and how to address them using synchronization mechanisms like locks, semaphores, and condition variables. The examples provided demonstrate the implementation of parallel programs using threads and processes in python, as well as the implementation of a simple tcp client-server application. This document could be useful for students studying topics related to concurrent and distributed systems, network programming, and software engineering.
Typology: Essays (high school)
1 / 61
This page cannot be seen from the preview
Don't miss anything!






















































Explicit parallelism
Implicit Parallelism
Methods for parallelism Message Passing:
Steps in Parallelism
import multiprocessing def worker(num): print('Worker:', num) for i in range(num): print(i) return jobs = [] for i in range(1,5): p = multiprocessing.Process(target=worker, args=(i+10,)) jobs.append(p) p.start()
import threading x = 0 # A shared value COUNT = 100 def incr(): global x for i in range(COUNT): x += 1 print(x) def decr(): global x for i in range(COUNT): x -= 1 print(x) t1 = threading.Thread(target=incr) t2 = threading.Thread(target=decr) t1.start() t2.start() t1.join() t2.join() print(x)