<commit_before>Tasks
=====
A simple task library for Arduino, using setjmp/longjmp inspired by [LWP](https://github.com/jscrane/lwp).

Example
-------
    
    #include <setjmp.h>
    #include <Tasks.h>

    static task_t task;
    static word stack[128];
    static sem_t sem;

    void run() {
        for (;;) {
                digitalWrite(0, LOW);
                delay(1000);
                sem_wait(&sem);
        }
    }

    void setup() {
        task_init();
        task_create(&task, &stack[127], run);
        sem_init(&sem, 0);
        pinMode(0, OUTPUT);
    }

    void loop() {
        digitalWrite(0, HIGH);
        delay(1000);
        sem_signal(&sem);
        task_yield();
    }<commit_msg>description<commit_after>Tasks
=====
A simple task library for Arduino, using setjmp/longjmp inspired by [LWP](https://github.com/jscrane/lwp).

Example
-------
    
    #include <setjmp.h>
    #include <Tasks.h>

    static task_t task;
    static word stack[128];
    static sem_t sem;

    void run() {
        for (;;) {
                digitalWrite(0, LOW);
                delay(1000);
        	sem_signal(&sem);
        	task_yield();
        }
    }

    void setup() {
        task_init();
        task_create(&task, &stack[127], run);
        sem_init(&sem, 0);
        pinMode(0, OUTPUT);
    }

    void loop() {
        digitalWrite(0, HIGH);
        delay(1000);
        sem_wait(&sem);
    }

Remarks
-------
* There are two tasks, one explicitly created, and the other implicit (i.e., 
the "main task").
* Tasks are of equal priority and run until completion, i.e., until they
run out of things to do; by blocking on a semaphore or explicitly yielding
the processor.
* In the example, the main thread switches on an LED on PB0 (this is an
ATtiny85), delays for a second and blocks on the semaphore.
* When the second thread runs, it turns off the LED and sleeps for a second
before releasing the main thread and yielding to it.
{'fraction_non_alphanumeric': 0.12468063362289218, 'fraction_numerical': 0.01992846193152785, 'mean_word_length': 2.1277955271565494, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4748831', 'n_tokens_mistral': 651, 'n_tokens_neox': 602, 'n_words': 193}