Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Single User Multi Tasking on Raspberry Pi-(Part 11/38)

By Ajish Alfred September 6, 2013

The Raspberry pi is a mini computer which is designed in a single board with all the essential components required for running an operating system. The Raspberry pi board runs on ARM11 processor but is available at extremely cheap price. The board is provided with a RCA connector which can be used to connect it directly to a TV screen which is based on PAL and NTSC standard. The board also has a HDMI connector output which can be used to connect the board to a HD TV.

There is an Ethernet port which can be used to connect the board to a computer network.. Those who don’t want to use a HDTV and separate keyboard and mouse for the Rspberrypi board can plug the board using a LAN cable to the Ethernet port of the PC and do remote access in TUI or GUI mode. The operating systems like Archlinux ARM, OpenELEC, Pidora, Raspbmc, RISC OS and the Raspbian and also Ubuntu versions are available for the Raspberrypi board.

Linux operating systems especially Ubuntu is preferred for all kind of programming and development. For accessing the Broadcom chip peripherals like timers, interrupt controller, GPIO, I2C, SPI, PWM, UART etc. using C code there is a library file called “bcm2835”. The immediate advantage of having an Operating System like Ubuntu running on an embedded system device is multitasking. All Linux OS provides Multi-user Multitasking feature. This article discusses how to perform single user multitasking in a Raspberrypi board. 

 


 

In this project the Raspberrypi board is loaded with Ubuntu and is remotely accessed using VNC. The Raspberrypi board is also connected to the internet. There are 26 connectors which can be taken out from the connector port of the Raspberrypi board. All the connector pins are taken out using 13*2 pin female connectors and at the other end of their wire 26 pin Burg stick male connectors are attached. The Burg stick male connectors allow each pin out from the Raspberrypi board to be plugged into the holes of a breadboard.  To access the pins that coming out of the Broadcom controller of the Raspberrypi board using C language, a C library is available called “bcm2835” which has been downloaded and installed.

There are eight general purpose IO pins on the 13*2 pin connectors of the Raspberrypi board and to each one of them a LED is connected through 1K resistor. Separate code has been written to blink the LEDs individually and made them executable. The code for blinking LED connected to one of the general purpose IO is given below:

This code can blink the LED connected to the GPIO_0 (PIN_11) of the Raspberrypi board. The user can use vim editor to write the code and save into a file, say “blink1.c”. From command line it uses the following command to compile the code with the new library file to generate the executable file “blink1”.

cc blink1.c -lbcm2835 -o blink1

Similarly the code for blinking the LEDs connected to each of the IO pins are written and compiled to make executable files named blink2, blink3, blink4, blink5, blink6, blink7 and blink8. It is suggested to keep all the .c files and the executable files in a single folder for this particular project.

 

The user can run any of the LED blinking programs from the command line. For example to execute the file ‘blink1’, the user can use the following command:

./blink1

Normally to run another executable file from the same command line, the user normally has to wait till the current program stops executing. The user can terminate the execution using the ‘kill’ command also as given below:

killall blink1

In this case the user is able to run a single task at a time and has to wait till the task to complete. This is an example of Single-User-Single-Tasking.

When using the GUI mode the user can simply open a new terminal and execute another program, but is not possible in case there is only TUI. The user can do Multi-tasking from the TUI by executing each and every code as a background process.

The user can execute the ‘blink1’ as a background process using the following command and then he/she will be provided with a terminal prompt again from where a new code can be executed.

./blink1 &

Now the user can execute the ‘blink2’ as a background process using the following command and again he/she will be provided with a terminal prompt from where a new code can be executed.

./blink2 &

This way the user can run as many code as he/she wish simultaneously and this is an example of Single-User-Multi-Tasking. Thus the user can perform multi-tasking with the eight LED codes by entering the following eight commands one after the other.

 ./blink1 &

./blink2 &

./blink3 &

./blink4 &

./blink5 &

./blink6 &

./blink7 &

./blink8 &

The following is a screenshot of the Single-User-Multitasking example which blinks eight LEDs connected to the GPIOs of the Raspberrypi board by executing eight individual codes simultaneously.

Example of Single-User-Multi-Tasking

Fig. 2: Example of Single-User-Multi-Tasking

 

This will create eight background processes which the Ubuntu OS will execute simultaneously due to its multitasking feature. All the processes that are currently running in the OS can be listed using the following command:

ps –e

 

 

 

Command to list all processes running in OS

Fig. 3: Command to list all processes running in OS

 

 The newly created process will appear at the end of the list as shown in the following image:

 

List of newly created process in Linux OS

Fig. 4: List of newly created process in Linux OS

 

The numbers listed in the left most row is the ‘process-id’. Every process running in the Linux OS has a similar number associated to it called the process-id.

The user can terminate the required process say ‘blink1’ using its name as:

killall blink1

or using its process-id as:

kill 2641

***Note that in this project the latest version of library “bcm2835” is used with an old version of Raspberrypi board. It is not possible to access the pin number 13 of the old board with the latest library version and hence in the code “blink3.c” the pin number 24 is used to blink the 3rd LED. The circuit diagram is also drawn accordingly. Those who have the latest version of the board can use the pin 13 without any trouble.

To find the ‘Revision’ and other important details about the Raspberrypi board, use the following command:

cat /proc/cpuinfo

*******************************************************************************
Note:
In this project the Raspberrypi board version 2 is used, but a previous version of the “bcm2835” library is installed. Accessing the GPIO pin 13 is not possible with this library and hence the 3rd IO pin is selected as pin24 of the P1 port of the Raspberrypi. The circuit and the code are modified accordingly. Those who have the version 2 of the Raspberrypi and the latest version of the “bcm2835” library can use the GPIO pin 13 using “RPI_V2_GPIO_P1_13” instead of “RPI_GPIO_P1_13” in the pin definition.
For example to define a ‘PIN’ as 13th pin of P1 port of Raspberrypi board version2, use the following statement in the code;
#define PIN RPI_V2_GPIO_P1_13

 

*******************************************************************************

 

Project Source Code

###

//------------------------------------------ led blinking code --------------------------------------------------//
#include <bcm2835.h>
#define PIN RPI_GPIO_P1_11

int main()
{
if (!bcm2835_init()) // initialize the library
return 1;

bcm2835_gpio_fsel (PIN, BCM2835_GPIO_FSEL_OUTP); // Set the pin to be an output

while (1)
{
bcm2835_gpio_write(PIN, HIGH); // Turn it on
bcm2835_delay(500); // wait a bit
bcm2835_gpio_write(PIN, LOW); // turn it off
bcm2835_delay(500); // wait a bit
}
bcm2835_close(); // close the library

return 0;
}

//------------------------------------------ led blinking code --------------------------------------------------//
 

###

 


Circuit Diagrams

Circuit-Diagram-Single-User-Multitasking-using-Raspberry-Pi

Project Components

  • LED
  • Resistor

Project Video


Filed Under: Raspberry pi
Tagged With: multi-tasking, Raspberry Pi
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • How can I get the frequency please help!
  • differential amplifier with active load
  • Battery sensing circuitry for coin cell application
  • I/O constraint for Hold check
  • Question LCD LED IPS display

RSS Electro-Tech-Online.com Discussions

  • 100uF bypass Caps?
  • how to work on pcbs that are thick
  • Fuel Auto Shutoff
  • Actin group needed for effective PCB software tutorials
  • compatible eth ports for laptop

Featured – Designing of Audio Amplifiers part 9 series

  • Basics of Audio Amplifier – 1/9
  • Designing 250 Milli Watt Audio Power Amplifier – 2/9
  • Designing 1 Watt Audio Power Amplifier – 3/9
  • Designing a Bass Boost Amplifier – 4/9
  • Designing a 6 Watt Car Audio Amplifier – 5/9
  • Design a low power amplifier for headphones- 6/9

Recent Articles

  • ITG Electronics releases gate drive transformers with 200 – 450 V DC capability
  • Stackpole introduces HCJ jumpers with 70.7 amp continuous current capability
  • Infineon releases MCU with 128K flash and multi-sense capabilities
  • ST introduces 600V GaN gate drivers with 300 ns start-up time
  • ABLIC releases S-19116 automotive voltage detector with 6.8μs response time

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe