Multitasking with Raspberry Pi [Team-IRA]
โ Scribed by Dogan Ibrahim
- Publisher
- Elektor Verlag
- Year
- 2020
- Tongue
- English
- Leaves
- 232
- Category
- Library
No coin nor oath required. For personal study only.
โฆ Synopsis
Multitasking and multiprocessing have become a very important topic in microcontroller-based systems, namely in complex commercial, domestic, and industrial automation applications. As the complexity of projects grows, more functionalities are demanded from the projects. Such projects require the use of multiple inter-related tasks running on the same system and sharing the available resources, such as the CPU, memory, and input-output ports. As a result of this, the importance of multitasking operations in microcontroller-based applications has grown steadily over the last few years. Many complex automation projects now make use of some form of a multitasking kernel.
This book is project-based and its main aim is to teach the basic features of multitasking using the Python 3 programming language on Raspberry Pi. Many fully tested projects are provided in the book using the multitasking modules of Python. Each project is described fully and in detail. Complete program listings are given for each project. Readers should be able to use the projects as they are, or modify them to suit their own needs.
The following Python multitasking modules have been described and used in the projects:
- Fork
- Thread
- Threading
- Subprocess
- Multiprocessing
The book includes simple multitasking projects such as independently controlling multiple LEDs, to more complex multitasking projects such as on/off temperature control, traffic lights control, 2-digit, and 4-digit 7-segment LED event counter, reaction timer, stepper motor control, keypad based projects, car park controller, and many more. The fundamental multitasking concepts such as process synchronization, process communication, and memory sharing techniques have been described in projects concerning event flags, queues, semaphores, values, and so on.
โฆ Table of Contents
Multitasking with Raspberry Pi
All rights reserved
Contents
Preface
1 โข Installing the Raspberry Pi operating system
1.1 Overview
1.2 Raspbian Buster installation steps on Raspberry Pi 4
1.3 Remote access
1.4 Using Putty
1.5 Remote access of the desktop
1.6 Summary
2 โข Using the Raspberry Pi command line
2.1 Overview
2.2 Command examples
2.3 Installing and removing software
2.4 Shutting down
2.5 Summary
3 โข Process management and resource monitoring on Raspberry Pi
3.1 Overview
3.2 Foreground and background processing
3.3 Task scheduling
3.4 Running a program or script automatically at system startup
3.5 Resource monitoring
3.6 Summary
4 โข Multiprocessing and multithreading
4.1 Overview
4.2 What is multithreading?
4.3 What is multiprocessing?
4.4 Differences between multithreading and multiprocessing
4 5 Task Scheduling algorithms
4.6 Summary
5 โข Raspberry Pi multitasking projects - using the fork()
5.1 Overview
5.2 Running shell commands from Python
5.3 Process forks
Project 1 โ Two LEDs flashing at different rates
Project 2 โ Four LEDs flashing at different rates
Project 3 โ Setting the LED flashing rate from the keyboard
Project 4 โ Multitasking event counter
Project 5 โ LED flashing and LED control with a button
Project 6 โ Synchronizing the parent and child processes - multitasking event counter
Project 7 โ Up/down counter
5.4 Summary
6 โข Raspberry Pi multitasking projects - using threads
6.1 Overview
6.2 Threads
6.3 Forking or Threads?
6.4 Using threads
Project 1 โ Two LEDs flashing at different rates
Project 2 โ Up/down counter
Project 3 โ Setting the LED flashing rate from the keyboard
Project 4 โ Setting the LED flashing rate using a button
Project 5 โ Two-digit 7-segment display seconds counter
Project 6 โ Two digit 7-segment temperature display
Project 7 โ Square waveform generator with 7-segment LED display and keyboard
Project 8 โ Square waveform generator with 7-segment LED display and buttons
Project 9 โ Four-digit 7-segment display seconds counter
Project 10 โ Four-digit 7-segment display conveyor belt object counter
Project 11 โ ON/OFF temperature controller with LCD
6.5 Summary
7 โข Raspberry Pi multitasking projects - using threading
7.1 Overview
7.2 Threading
7.3 Threading based projects
7.4 Summary
8 โข Using subprocesses
8.1 Overview
8.2 Subprocesses call
8.3 Subprocess run
8.4 Subprocess check_call
8.5 Subprocess check_output
8.6 Subprocess Popen and communicate
8.7 Running a Python program
8.8 Project 1 โ Two LEDs flashing at different rates
8.9 Summary
9 โข Raspberry Pi multitasking projects - using multiprocessing
9.1 Overview
9.2 Multiprocessing or threading?
9.3 How many CPU cores?
9.4 Multiprocessing process calls
9.5 Using Events in multiprocessing
9.6 Conditions in multiprocessing
9.7 Multiprocessing Queues
9.8 Sharing data in multiprocessing using Value and Array
9.9 Anonymous Pipes in multiprocessing
9.10 Named Pipes
9.11 Signals in multiprocessing
9.12 Multiprocessing based projects
Project 1 - Two LEDs flashing at different rates
Project 2 โ Setting the LED flashing rate from the keyboard
Project 3 - ON/OFF temperature controller
Project 4 - Metronome
Project 5 โ Traffic lights controller
Project 6 โ Ultrasonic car parking aid with buzzer
Project 7 โ Reaction timer
Project 8 โ Stepper motor controller with keyboard
Project 9 โ Setting the flashing rate of an LED with keypad
Project 10 โ Secure door lock with keypad
Project 11 โ Car park control
Appendix
Appendix A โข List of components used in the book
Appendix B โข Raspberry Pi 4 pin configuration
Index
๐ SIMILAR VOLUMES
<p><span>The Raspberry Pi is a very cheap but complete computer system that allows all sorts of electronics parts and extensions to be connected. This book addresses one of the strongest aspects of the Raspberry Pi: the ability to combine hands-on electronics and programming.</span></p><span> Combin
A technology book for kids! Do you want to learn how computers work? This book introduces you to the world of computing with the Raspberry Pi - the small, inexpensive, and super-cool microcomputer that teaches real tech skills. Use the Pi to create things while learning all about computers, from the
"Do you want to learn how computers work? This book introduces you to the world of computing with the Raspberry Pi - the small, inexpensive, and super-cool microcomputer that teaches real tech skills. Use the Pi to create things while learning all about computers, from the inside out!"--Back cover.
"Do you want to learn how computers work? This book introduces you to the world of computing with the Raspberry Pi - the small, inexpensive, and super-cool microcomputer that teaches real tech skills. Use the Pi to create things while learning all about computers, from the inside out!"--Back cover.
Need some inspiration for your Raspberry Pi projects? Wondering how to work with Wii nunchucks, stepper motors, how to create a remote control panel? If you need guidance, Experimenting with Raspberry Pi is your own personal idea generator. Experimenting with Raspberry Pi covers how to work with var