core: renamed KERNEL_PID_NULL to KERNEL_PID_UNDEF

As @authmillenon pointed out the "null" in the old name is somewhat
misleading, since the actual value is -1.
dev/timer
Oleg Hahm 9 years ago
parent 4b1a2f32eb
commit c2b0423918

@ -5,10 +5,10 @@
#include <inttypes.h>
/**
* @def KERNEL_PID_NULL
* @def KERNEL_PID_UNDEF
* @brief Identifier to detect an invalid PID
*/
#define KERNEL_PID_NULL -1
#define KERNEL_PID_UNDEF -1
/**
* Macro for printing formatter

@ -43,7 +43,7 @@ volatile unsigned int sched_context_switch_request;
volatile tcb_t *sched_threads[MAXTHREADS];
volatile tcb_t *sched_active_thread;
volatile kernel_pid_t sched_active_pid = KERNEL_PID_NULL;
volatile kernel_pid_t sched_active_pid = KERNEL_PID_UNDEF;
clist_node_t *sched_runqueues[SCHED_PRIO_LEVELS];
static uint32_t runqueue_bitcache = 0;

@ -136,7 +136,7 @@ typedef void (*x86_rtc_callback_t)(uint8_t reg_c);
* @brief Set an RTC alarm.
* @param[in] when Time when the RTC you raise an interrupt. The date part is ignored.
* @param msg_content The value for msg_t::content.value.
* @param target_pid The process which shall receive the message, `KERNEL_PID_NULL` to disable.
* @param target_pid The process which shall receive the message, `KERNEL_PID_UNDEF` to disable.
* @param allow_replace Whether it is allowed to overwrite an existing alarm.
*
* The value of msg_t::type will be `reg_c | (RTC_REG_B_INT_UPDATE << 8)`,
@ -151,7 +151,7 @@ bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, kernel_
* @brief Set up periodic interrupts
* @param hz How often a second the interrupt should fire, e.g. RTC_REG_A_HZ_8192.
* @param msg_content The value for msg_t::content.value.
* @param target_pid The process which shall receive the message, `KERNEL_PID_NULL` to disable.
* @param target_pid The process which shall receive the message, `KERNEL_PID_UNDEF` to disable.
* @param allow_replace Whether it is allowed to overwrite an existing alarm.
*
* The value of msg_t::type will be `reg_c | (RTC_REG_B_INT_PERIODIC << 8)`,
@ -165,7 +165,7 @@ bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, kernel_pid_t target_
/**
* @brief Set up secondly interrupts.
* @param msg_content The value for msg_t::content.value.
* @param target_pid The process which shall receive the message, `KERNEL_PID_NULL` to disable.
* @param target_pid The process which shall receive the message, `KERNEL_PID_UNDEF` to disable.
* @param allow_replace Whether it is allowed to overwrite an existing alarm.
*
* The value of msg_t::type will be `reg_c | (RTC_REG_B_INT_UPDATE << 8)`,

@ -113,7 +113,7 @@ static void measure_nop_nop_nops_per_tick(void)
ts_per_nop_nop_nop += counting_end - counting_start;
}
x86_rtc_set_periodic_callback(NULL);
x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_NULL, false);
x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_UNDEF, false);
/* instructions_per_second = nop_nop_nops_per_second * ts_per_nop_nop_nop: */
instructions_per_second = nop_nop_nops_per_tick * TICK_HZ_VAL * ts_per_nop_nop_nop / nop_nop_nops_per_tick / NNN_TICK_ITERATIONS;
@ -150,7 +150,7 @@ static void init_bases(void)
ts_base);
x86_rtc_set_periodic_callback(NULL);
x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_NULL, false);
x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_UNDEF, false);
}
void x86_init_hwtimer(void)
@ -231,17 +231,17 @@ static void stop_alarms(void)
if (rtc_alarm_ie) {
rtc_alarm_ie = 0;
x86_rtc_set_alarm(NULL, 0, KERNEL_PID_NULL, false);
x86_rtc_set_alarm(NULL, 0, KERNEL_PID_UNDEF, false);
}
if (rtc_update_ie) {
rtc_update_ie = 0;
x86_rtc_set_update(0, KERNEL_PID_NULL, false);
x86_rtc_set_update(0, KERNEL_PID_UNDEF, false);
}
if (rtc_periodic_ie) {
rtc_periodic_ie = 0;
x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_NULL, false);
x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_UNDEF, false);
}
}

@ -42,11 +42,11 @@
static bool valid;
static int32_t alarm_msg_content, periodic_msg_content, update_msg_content;
static unsigned alarm_pid = KERNEL_PID_NULL, periodic_pid = KERNEL_PID_NULL, update_pid = KERNEL_PID_NULL;
static unsigned alarm_pid = KERNEL_PID_UNDEF, periodic_pid = KERNEL_PID_NULL, update_pid = KERNEL_PID_NULL;
static void alarm_callback_default(uint8_t reg_c)
{
if (alarm_pid != KERNEL_PID_NULL) {
if (alarm_pid != KERNEL_PID_UNDEF) {
msg_t m;
m.type = reg_c | (RTC_REG_B_INT_ALARM << 8);
m.content.value = alarm_msg_content;
@ -56,7 +56,7 @@ static void alarm_callback_default(uint8_t reg_c)
static void periodic_callback_default(uint8_t reg_c)
{
if (periodic_pid != KERNEL_PID_NULL) {
if (periodic_pid != KERNEL_PID_UNDEF) {
msg_t m;
m.type = reg_c | (RTC_REG_B_INT_PERIODIC << 8);
m.content.value = periodic_msg_content;
@ -66,7 +66,7 @@ static void periodic_callback_default(uint8_t reg_c)
static void update_callback_default(uint8_t reg_c)
{
if (update_pid != KERNEL_PID_NULL) {
if (update_pid != KERNEL_PID_UNDEF) {
msg_t m;
m.type = reg_c | (RTC_REG_B_INT_UPDATE << 8);
m.content.value = update_msg_content;
@ -206,15 +206,15 @@ bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, kernel_
unsigned old_status = disableIRQ();
bool result;
if (target_pid == KERNEL_PID_NULL) {
if (target_pid == KERNEL_PID_UNDEF) {
result = true;
alarm_pid = KERNEL_PID_NULL;
alarm_pid = KERNEL_PID_UNDEF;
uint8_t b = x86_cmos_read(RTC_REG_B);
x86_cmos_write(RTC_REG_B, b & ~RTC_REG_B_INT_ALARM);
}
else {
result = allow_replace || alarm_pid == KERNEL_PID_NULL;
result = allow_replace || alarm_pid == KERNEL_PID_UNDEF;
if (result) {
alarm_msg_content = msg_content;
alarm_pid = target_pid;
@ -246,16 +246,16 @@ bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, kernel_pid_t target_
unsigned old_status = disableIRQ();
bool result;
if (target_pid == KERNEL_PID_NULL || hz == RTC_REG_A_HZ_OFF) {
if (target_pid == KERNEL_PID_UNDEF || hz == RTC_REG_A_HZ_OFF) {
result = true;
periodic_pid = KERNEL_PID_NULL;
periodic_pid = KERNEL_PID_UNDEF;
uint8_t old_divider = x86_cmos_read(RTC_REG_A) & ~RTC_REG_A_HZ_MASK;
x86_cmos_write(RTC_REG_A, old_divider | RTC_REG_A_HZ_OFF);
x86_cmos_write(RTC_REG_B, x86_cmos_read(RTC_REG_B) & ~RTC_REG_B_INT_PERIODIC);
}
else {
result = allow_replace || periodic_pid == KERNEL_PID_NULL;
result = allow_replace || periodic_pid == KERNEL_PID_UNDEF;
if (result) {
periodic_msg_content = msg_content;
periodic_pid = target_pid;
@ -278,14 +278,14 @@ bool x86_rtc_set_update(uint32_t msg_content, kernel_pid_t target_pid, bool allo
unsigned old_status = disableIRQ();
bool result;
if (target_pid == KERNEL_PID_NULL) {
if (target_pid == KERNEL_PID_UNDEF) {
result = true;
update_pid = KERNEL_PID_NULL;
update_pid = KERNEL_PID_UNDEF;
x86_cmos_write(RTC_REG_B, x86_cmos_read(RTC_REG_B) & ~RTC_REG_B_INT_UPDATE);
}
else {
result = allow_replace || update_pid == KERNEL_PID_NULL;
result = allow_replace || update_pid == KERNEL_PID_UNDEF;
if (result) {
update_msg_content = msg_content;
update_pid = target_pid;

@ -51,7 +51,7 @@ static ucontext_t end_context;
bool x86_in_isr = true;
static kernel_pid_t fpu_owner = KERNEL_PID_NULL;
static kernel_pid_t fpu_owner = KERNEL_PID_UNDEF;
//static ucontext_t *cur_ctx, *isr_ctx;
@ -188,7 +188,7 @@ static void fpu_used_interrupt(uint8_t intr_num, struct x86_pushad *orig_ctx, un
return;
}
if (fpu_owner != KERNEL_PID_NULL) {
if (fpu_owner != KERNEL_PID_UNDEF) {
ucontext_t *ctx_owner = (ucontext_t *) sched_threads[fpu_owner]->sp;
asm volatile ("fxsave (%0)" :: "r"(&fpu_data));
ctx_owner->__fxsave = fpu_data;
@ -205,7 +205,7 @@ static void x86_thread_exit(void)
{
dINT();
if (fpu_owner == sched_active_pid) {
fpu_owner = KERNEL_PID_NULL;
fpu_owner = KERNEL_PID_UNDEF;
}
sched_task_exit();
}

@ -61,7 +61,7 @@ void at86rf231_rx_handler(void)
#endif
/* notify transceiver thread if any */
if (transceiver_pid > KERNEL_PID_NULL) {
if (transceiver_pid > KERNEL_PID_UNDEF) {
msg_t m;
m.type = (uint16_t) RCV_PKT_AT86RF231;
m.content.value = rx_buffer_next;

@ -173,7 +173,7 @@ void cc1100_phy_init(void)
memset(seq_buffer, 0, sizeof(seq_buffer_entry_t) * MAX_SEQ_BUFFER_SIZE);
/* Initialize mutex */
cc1100_mutex_pid = KERNEL_PID_NULL;
cc1100_mutex_pid = KERNEL_PID_UNDEF;
/* Allocate event numbers and start cc1100 event process */
cc1100_event_handler_pid = thread_create(event_handler_stack, sizeof(event_handler_stack), PRIORITY_CC1100, CREATE_STACKTEST,
@ -203,7 +203,7 @@ void cc1100_phy_mutex_lock(void)
void cc1100_phy_mutex_unlock(void)
{
cc1100_mutex_pid = KERNEL_PID_NULL;
cc1100_mutex_pid = KERNEL_PID_UNDEF;
mutex_unlock(&cc1100_mutex);
}

@ -86,7 +86,7 @@ void cc110x_rx_handler(void)
#endif
/* notify transceiver thread if any */
if (transceiver_pid > KERNEL_PID_NULL) {
if (transceiver_pid > KERNEL_PID_UNDEF) {
msg_t m;
m.type = (uint16_t) RCV_PKT_CC1100;
m.content.value = rx_buffer_next;

@ -78,7 +78,7 @@ void cc2420_rx_handler(void)
#endif
/* notify transceiver thread if any */
if (transceiver_pid > KERNEL_PID_NULL) {
if (transceiver_pid > KERNEL_PID_UNDEF) {
msg_t m;
m.type = (uint16_t) RCV_PKT_CC2420;
m.content.value = rx_buffer_next;

@ -47,7 +47,7 @@ void chardev_loop(ringbuffer_t *rb)
kernel_pid_t pid = thread_getpid();
kernel_pid_t reader_pid = KERNEL_PID_NULL;
kernel_pid_t reader_pid = KERNEL_PID_UNDEF;
struct posix_iop_t *r = NULL;
puts("UART0 thread started.");
@ -61,7 +61,7 @@ void chardev_loop(ringbuffer_t *rb)
switch(m.type) {
case OPEN:
DEBUG("OPEN\n");
if (reader_pid == KERNEL_PID_NULL) {
if (reader_pid == KERNEL_PID_UNDEF) {
reader_pid = m.sender_pid;
/* no error */
m.content.value = 0;
@ -90,7 +90,7 @@ void chardev_loop(ringbuffer_t *rb)
DEBUG("CLOSE\n");
if (m.sender_pid == reader_pid) {
DEBUG("uart0_thread: closing file from %" PRIkernel_pid "\n", reader_pid);
reader_pid = KERNEL_PID_NULL;
reader_pid = KERNEL_PID_UNDEF;
r = NULL;
m.content.value = 0;
}

@ -76,7 +76,7 @@ kernel_pid_t border_get_serial_reader()
void serial_reader_f(void)
{
kernel_pid_t main_pid = KERNEL_PID_NULL;
kernel_pid_t main_pid = KERNEL_PID_UNDEF;
int bytes;
msg_t m;
border_packet_t *uart_buf;

@ -52,9 +52,9 @@ ipv6_hdr_t *ipv6_buf;
icmpv6_hdr_t *icmp_buf;
uint8_t *nextheader;
kernel_pid_t udp_packet_handler_pid = KERNEL_PID_NULL;
kernel_pid_t tcp_packet_handler_pid = KERNEL_PID_NULL;
kernel_pid_t rpl_process_pid = KERNEL_PID_NULL;
kernel_pid_t udp_packet_handler_pid = KERNEL_PID_UNDEF;
kernel_pid_t tcp_packet_handler_pid = KERNEL_PID_UNDEF;
kernel_pid_t rpl_process_pid = KERNEL_PID_UNDEF;
ipv6_addr_t *(*ip_get_next_hop)(ipv6_addr_t *) = 0;
static ipv6_net_if_ext_t ipv6_net_if_ext[NET_IF_MAX];
@ -259,7 +259,7 @@ int icmpv6_demultiplex(const icmpv6_hdr_t *hdr)
case (ICMPV6_TYPE_RPL_CONTROL): {
DEBUG("INFO: packet type: RPL message\n");
if (rpl_process_pid != KERNEL_PID_NULL) {
if (rpl_process_pid != KERNEL_PID_UNDEF) {
msg_t m_send;
m_send.content.ptr = (char *) &hdr->code;
msg_send(&m_send, rpl_process_pid, 1);
@ -379,7 +379,7 @@ void *ipv6_process(void *arg)
}
case (IPV6_PROTO_NUM_TCP): {
if (tcp_packet_handler_pid != KERNEL_PID_NULL) {
if (tcp_packet_handler_pid != KERNEL_PID_UNDEF) {
m_send.content.ptr = (char *) ipv6_buf;
msg_send_receive(&m_send, &m_recv, tcp_packet_handler_pid);
}
@ -391,7 +391,7 @@ void *ipv6_process(void *arg)
}
case (IPV6_PROTO_NUM_UDP): {
if (udp_packet_handler_pid != KERNEL_PID_NULL) {
if (udp_packet_handler_pid != KERNEL_PID_UNDEF) {
m_send.content.ptr = (char *) ipv6_buf;
msg_send_receive(&m_send, &m_recv, udp_packet_handler_pid);
}

@ -123,10 +123,10 @@ uint8_t comp_buf[512];
uint8_t first_frag = 0;
mutex_t fifo_mutex = MUTEX_INIT;
kernel_pid_t ip_process_pid = KERNEL_PID_NULL;
kernel_pid_t nd_nbr_cache_rem_pid = KERNEL_PID_NULL;
kernel_pid_t contexts_rem_pid = KERNEL_PID_NULL;
kernel_pid_t transfer_pid = KERNEL_PID_NULL;
kernel_pid_t ip_process_pid = KERNEL_PID_UNDEF;
kernel_pid_t nd_nbr_cache_rem_pid = KERNEL_PID_UNDEF;
kernel_pid_t contexts_rem_pid = KERNEL_PID_UNDEF;
kernel_pid_t transfer_pid = KERNEL_PID_UNDEF;
mutex_t lowpan_context_mutex = MUTEX_INIT;
@ -1788,7 +1788,7 @@ int sixlowpan_lowpan_init(void)
/* init mac-layer and radio transceiver */
sixlowpan_mac_init();
if (ip_process_pid == KERNEL_PID_NULL) {
if (ip_process_pid == KERNEL_PID_UNDEF) {
ip_process_pid = thread_create(ip_process_buf, IP_PROCESS_STACKSIZE,
PRIORITY_MAIN - 1, CREATE_STACKTEST,
ipv6_process, NULL, "ip_process");

@ -60,9 +60,9 @@ static uint8_t etx_send_buf[ETX_BUF_SIZE];
static uint8_t etx_rec_buf[ETX_BUF_SIZE];
//PIDs
kernel_pid_t etx_beacon_pid = KERNEL_PID_NULL;
kernel_pid_t etx_radio_pid = KERNEL_PID_NULL;
kernel_pid_t etx_clock_pid = KERNEL_PID_NULL;
kernel_pid_t etx_beacon_pid = KERNEL_PID_UNDEF;
kernel_pid_t etx_radio_pid = KERNEL_PID_UNDEF;
kernel_pid_t etx_clock_pid = KERNEL_PID_UNDEF;
//Message queue for radio
static msg_t msg_que[ETX_RCV_QUEUE_SIZE];

@ -676,7 +676,7 @@ int destiny_socket_connect(int socket, sockaddr6_t *addr, uint32_t addrlen)
current_tcp_socket->tcp_control.state = TCP_ESTABLISHED;
current_int_tcp_socket->recv_pid = KERNEL_PID_NULL;
current_int_tcp_socket->recv_pid = KERNEL_PID_UNDEF;
destiny_socket_print_sockets();
return 0;
@ -1294,7 +1294,7 @@ int handle_new_tcp_connection(socket_internal_t *current_queued_int_socket,
msg_reply(&msg_recv_client_ack, &msg_send_client_ack);
/* Reset PID to an invalid value */
current_queued_int_socket->recv_pid = KERNEL_PID_NULL;
current_queued_int_socket->recv_pid = KERNEL_PID_UNDEF;
/* Waiting for Clients ACK waiting period to time out */
vtimer_usleep(TCP_SYN_INITIAL_TIMEOUT / 2);

@ -72,7 +72,7 @@ typedef struct pthread_thread {
static pthread_thread_t *volatile pthread_sched_threads[MAXTHREADS];
static struct mutex_t pthread_mutex;
static volatile int pthread_reaper_pid = KERNEL_PID_NULL;
static volatile int pthread_reaper_pid = KERNEL_PID_UNDEF;
static char pthread_reaper_stack[PTHREAD_REAPER_STACKSIZE];
@ -184,7 +184,7 @@ void pthread_exit(void *retval)
ct->__routine(ct->__arg);
}
self->thread_pid = KERNEL_PID_NULL;
self->thread_pid = KERNEL_PID_UNDEF;
DEBUG("pthread_exit(%p), self == %p\n", retval, (void *) self);
if (self->status != PTS_DETACHED) {
self->returnval = retval;

@ -88,7 +88,7 @@ msg_t msg_buffer[TRANSCEIVER_MSG_BUFFER_SIZE];
uint32_t response; ///< response bytes for messages to upper layer threads
volatile kernel_pid_t transceiver_pid = KERNEL_PID_NULL; ///< the transceiver thread's pid
volatile kernel_pid_t transceiver_pid = KERNEL_PID_UNDEF; ///< the transceiver thread's pid
static volatile uint8_t rx_buffer_pos = 0;
static volatile uint8_t transceiver_buffer_pos = 0;
@ -165,7 +165,7 @@ void transceiver_init(transceiver_type_t t)
for (i = 0; i < TRANSCEIVER_MAX_REGISTERED; i++) {
reg[i].transceivers = TRANSCEIVER_NONE;
reg[i].pid = KERNEL_PID_NULL;
reg[i].pid = KERNEL_PID_UNDEF;
}
/* check if a non defined bit is set */

Loading…
Cancel
Save