chrismoos / avr-os Goto Github PK
View Code? Open in Web Editor NEWMultitasking OS for Arduino and AVR platforms
License: Apache License 2.0
Multitasking OS for Arduino and AVR platforms
License: Apache License 2.0
I have noticed that you don't save RAMPZ and EIND registers during a context switch. RAMPZ can be important when reading data from flash that is located at high addresses (REF: Section 7.6.1 in the ATMega640-1280-2560 datasheet). This seems like it would be problematic if their is a context switch between two processes attempting to access strings that have been stored with the PRGMEM attribute.
If you agree this is the case, let me know and I'll look at making a patch for this issue.
There is a name collision between the mutex_t struct and the mutex_t type. Correction is easy by renaming the struct into mutex_s but I don't know how to propose a commit (git commit seems not working).
i have a problem using your code. i run the code in Readme but trap in setup. here is my code:
#include <Arduino.h>
#include <util/delay.h>
extern "C" {
#include <os.h>
}
spinlock_t testLock;
void kernel_task(void *arg) {
while(1) {
spinlock_acquire(&testLock);
Serial.println("kernel: " + String((long)os_get_uptime()));
spinlock_release(&testLock);
os_sleep(1000);
}
}
void user_task(void *arg) {
int x = 0;
while(1) {
spinlock_acquire(&testLock);
Serial.println("user_task: " + String(x++));
spinlock_release(&testLock);
os_sleep(5000);
}
}
void setup() {
Serial.begin(9600);
Serial.print("Begin.\n");
os_init();
}
void loop() {
spinlock_init(&testLock);
os_schedule_task(kernel_task, NULL, 0);
os_schedule_task(user_task, NULL, 0);
os_loop();
}
and here is the result keep running the setup:
i am using arduino mega2560. and i put your code in Arduino/libraries/os.
Hi, Chris Moos
I realize that we need to input "make DEVICE=arduino_*" everytime we make
and I do some change on Makefile, it will prompt and take input from user
btw, I also make changes on arduino/common.mk too...
as I added Include path on compile flags
I will send u the diff file later.
Regards,
Chalos
Hi @chrismoos
I facing a problem when running sample code on Mega2560, which it's works on Uno.
Sample Code:
#include "Arduino.h"
#include <Wire.h>
#include "LiquidCrystal/LiquidCrystal_I2C.h"
#include <util/delay.h>
extern "C" {
#include "avros/os.h"
}
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
spinlock_t mutex;
void kernel_task(void *arg) {
while(1) {
spinlock_acquire(&mutex);
lcd.setCursor(0, 0);
lcd.print("kernel: " + String((long)os_get_uptime()));
spinlock_release(&mutex);
os_sleep(1000);
}
}
void user_task(void *arg) {
int x = 0;
while(1) {
spinlock_acquire(&mutex);
lcd.setCursor(0, 1);
lcd.print("user_task: " + String(x++));
spinlock_release(&mutex);
os_sleep(2000);
}
}
void setup() {
lcd.begin(16, 2);
lcd.print("...");
os_init();
}
void loop() {
spinlock_init(&mutex);
os_schedule_task(kernel_task, NULL, 0);
os_schedule_task(user_task, NULL, 1);
os_loop();
}
This is the result when running on Mega2560, it is stucking after calling os_init()
But same code run on Uno, it is works...
Thanks.
Chalos
Hi !
I'm very interested by avr-os (and multitasking on Arduino).
I downloaded the whole library (by a "git clone...") and tested the example. By the way, I have an Arduino UNO with a LCD wired as needed. While the sketch compiles fine, he does not work at all and lock the Arduino. I use arduino 1.0.1 on Debian Linux.
I tried to comment some lines to try to find the failing statement(s) and I found that it is sufficent to include the "os.h" (and then to compile the *.c files) to lock the Arduino.
I'll investigate deeper to try to find out where exactly is the problem, but I'd like to know if this library has already be tested on a Arduino UNO. I wonder if there is a potential limited RAM issue.
Thanks,
Alexandre
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.