mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 22:13:52 +01:00
remove sixlowpans own semaphore and use new riot semaphore in flowcontrol
This commit is contained in:
parent
39d5299f69
commit
9b84d62357
@ -71,7 +71,7 @@ ipv6_addr_t flowcontrol_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
sem_init(&slwin_stat.send_win_not_full, BORDER_SWS);
|
||||
sem_init(&slwin_stat.send_win_not_full, 0, BORDER_SWS);
|
||||
|
||||
for (i = 0; i < BORDER_SWS; i++) {
|
||||
slwin_stat.send_win[i].frame_len = 0;
|
||||
@ -162,7 +162,7 @@ void flowcontrol_deliver_from_uart(border_packet_t *packet, int len)
|
||||
if (in_window(packet->seq_num, slwin_stat.last_ack + 1, slwin_stat.last_frame)) {
|
||||
if (synack_seqnum == packet->seq_num) {
|
||||
synack_seqnum = -1;
|
||||
sem_signal(&connection_established);
|
||||
sem_post(&connection_established);
|
||||
}
|
||||
|
||||
do {
|
||||
@ -170,7 +170,7 @@ void flowcontrol_deliver_from_uart(border_packet_t *packet, int len)
|
||||
slot = &(slwin_stat.send_win[++slwin_stat.last_ack % BORDER_SWS]);
|
||||
vtimer_remove(&slot->timeout);
|
||||
memset(&slot->frame, 0, BORDER_BUFFER_SIZE);
|
||||
sem_signal(&slwin_stat.send_win_not_full);
|
||||
sem_post(&slwin_stat.send_win_not_full);
|
||||
}
|
||||
while (slwin_stat.last_ack != packet->seq_num);
|
||||
}
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Semaphore implemenation
|
||||
*
|
||||
* Copyright (C) 2013 INRIA.
|
||||
*
|
||||
* This file subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*
|
||||
* @ingroup sixlowpan
|
||||
* @{
|
||||
* @file semaphore.c
|
||||
* @brief Implemntation of semaphores using mutexes
|
||||
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
|
||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "semaphore.h"
|
||||
|
||||
void sem_init(sem_t *sem, int8_t value)
|
||||
{
|
||||
sem->value = value;
|
||||
mutex_init(&sem->mutex);
|
||||
sem->locked = 0;
|
||||
}
|
||||
|
||||
int sem_wait(sem_t *sem)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (--(sem->value) <= 0 && !sem->locked) {
|
||||
sem->locked = !(sem->locked);
|
||||
res = mutex_lock(&(sem->mutex));
|
||||
|
||||
if (res < 0) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sem_signal(sem_t *sem)
|
||||
{
|
||||
if (++(sem->value) > 0 && sem->locked) {
|
||||
sem->locked = !(sem->locked);
|
||||
mutex_unlock(&(sem->mutex));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
/**
|
||||
* Semaphore data struct and prototypes
|
||||
*
|
||||
* Copyright (C) 2013 INRIA.
|
||||
*
|
||||
* This file subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*
|
||||
* @ingroup sixlowpan
|
||||
* @{
|
||||
* @file semaphore.h
|
||||
* @brief data struct and prototypes for semaphores
|
||||
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
|
||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef _SIXLOWPAN_SEMAPHORE_H
|
||||
#define _SIXLOWPAN_SEMAPHORE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mutex.h"
|
||||
|
||||
typedef struct sem_t {
|
||||
int8_t value;
|
||||
int8_t locked;
|
||||
mutex_t mutex;
|
||||
} sem_t;
|
||||
|
||||
void sem_init(sem_t *sem, int8_t value);
|
||||
int sem_wait(sem_t *sem);
|
||||
int sem_signal(sem_t *sem);
|
||||
|
||||
#endif /* _SIXLOWPAN_SEMAPHORE_H*/
|
||||
Loading…
x
Reference in New Issue
Block a user