Friday, 12 June 2020

Multiprocessing - Shared Variables, Lock, Queue

The script shows how to execute 4 processes simultaneously in Python by using the multiprocessing module. In this script, shared variables are defined which can be modified by processes, a message queue is also defined which allows communication between processes.

Four processes defined in this script are:
  1. Finding of Fibonacci numbers
  2. Finding prime numbers
  3. Estimation of Pi
  4. Output of results from other processes
The function getchar() is used in the main program, it can wait for key input from the console without requiring the user to press [Enter].

Reference

Python multiprocessing, ctypes

Source Code



Here is the script.


A sample result of running this program is given below

No comments:

Post a Comment