Projekte
workwind
Multitasking optimiert
condition.c
Projekte
Forum
Doku
Öffentliche Projekte
Startseite
Beispielprogramme
Projekte von anderen
Welcome
Username
Passwort
Eingeloggt bleiben
Zugangsdaten vergessen?
Registrieren
Projektverwaltung
⇨ Please choose! ⇦
——————————————————
✎ Create new project...
★ Browse existing projects...
——————————————————
⚬ MotorTest#1
⚬ C Tutorial 8#1
⚬ NIBO2 C Project#1
⚙ C Tutorial 15#1
⚬ 2010_11_18_el_test001#1
Multitask...optimiert
cdll.c
cdll.h
condition.c
condition.h
main.c
mutex.c
mutex.h
scheduler.S
semaphore.c
semaphore.h
thread.c
thread.h
Project details
Compiler settings
Nachrichten
Sie sind nicht eingeloggt.
Neuigkeiten
★
NiboRoboLib 3.6
2017-01-17: Neue Version 3.6
★
NiboRoboLib 3.4.1
2016-04-16: Neue Version 3.4.1
★
Coding Tutorial
2015-11-22: Jetzt auch für den NIBO burger!
Site-Statistic
7426 private projects
385 public projects
16180353 lines compiled
58212 builds
NIBO
@
multitasking_opt/condition.c [read only]
#include <avr/interrupt.h> #include "condition.h" /* cdll_t waiting_threads; */ void _mutext_lockCondition(mutex_t * mutex, uint8_t value); uint8_t _mutext_unlockCondition(mutex_t * mutex); void condition_init(condition_t * condition) { cdll_reset(&(condition->waiting_threads)); } void condition_delete(condition_t * condition) { } void _mutext_lockCondition(mutex_t * mutex, uint8_t value); uint8_t condition_wait(condition_t * condition, mutex_t * mutex, uint16_t timeout) { uint8_t result; cli(); thread_t * thread = thread_getCurrent(); if (timeout==TO_POLL) { // conditions can't be polled - return false result = 0; } else { // unlock mutex uint8_t mutexCnt = _mutext_unlockCondition(mutex); // wait for signal... cdll_push_back(&(condition->waiting_threads), &(thread->rivals_list)); if (timeout == TO_INF) { thread_wait(); result = 1; } else { result = thread_waitTimeout(timeout); } cdll_remove(&(thread->rivals_list)); // lock mutex _mutext_lockCondition(mutex, mutexCnt); // mutex is always locked at this position! } sei(); return result; } void condition_broadcast(condition_t * condition) { cli(); cdll_t * next = condition->waiting_threads.next; while (next != &condition->waiting_threads) { thread_t * t = THREAD_FROM_RIVALS_CDLL(next); thread_signalISR(t); } sei(); } void condition_broadcastISR(condition_t * condition) { cdll_t * next = condition->waiting_threads.next; while (next != &condition->waiting_threads) { thread_t * t = THREAD_FROM_RIVALS_CDLL(next); thread_signalISR(t); } } void condition_signal(condition_t * condition) { cli(); cdll_t * next = condition->waiting_threads.next; if (next != &condition->waiting_threads) { thread_t * t = THREAD_FROM_RIVALS_CDLL(next); thread_signalISR(t); } sei(); } void condition_signalISR(condition_t * condition) { cdll_t * next = condition->waiting_threads.next; if (next != &condition->waiting_threads) { thread_t * t = THREAD_FROM_RIVALS_CDLL(next); thread_signalISR(t); } }
Compiler results:
Werbung
Online
charlesvallejos297
FloKre
frederickajustice19
hopewyman5990749
jnplatesha8912130544
kaceywinters6603326
scotcornett35376
wthjohnson00956