Browse Source

core: harmonizes the data type for the process ID

Instead of using differing integer types use kernel_pid_t for process
identifier. This type is introduced in a new header file to avoid
circular dependencies.
dev/timer
Oleg Hahm 9 years ago
parent
commit
983d056c75
  1. 2
      boards/avsextrem/drivers/avsextrem-smb380.c
  2. 2
      boards/msba2-common/drivers/include/uart0.h
  3. 4
      core/include/kernel.h
  4. 18
      core/include/kernel_types.h
  5. 9
      core/include/msg.h
  6. 2
      core/include/sched.h
  7. 2
      core/include/tcb.h
  8. 10
      core/include/thread.h
  9. 20
      core/msg.c
  10. 4
      core/mutex.c
  11. 6
      core/sched.c
  12. 16
      core/thread.c
  13. 1
      cpu/arm_common/gettimeofday.c
  14. 4
      cpu/arm_common/syscalls.c
  15. 2
      cpu/cc430/cc430-rtc.c
  16. 2
      cpu/cortex-m3_common/thread_arch.c
  17. 2
      cpu/lpc1768/syscalls.c
  18. 2
      cpu/lpc2387/rtc/lpc2387-rtc.c
  19. 1
      cpu/native/include/native_internal.h
  20. 4
      cpu/native/include/nativenet.h
  21. 4
      cpu/native/net/interface.c
  22. 1
      cpu/native/syscalls.c
  23. 6
      cpu/sam3x8e/syscalls.c
  24. 12
      cpu/x86/include/x86_rtc.h
  25. 2
      cpu/x86/x86_glue.c
  26. 10
      cpu/x86/x86_hwtimer.c
  27. 34
      cpu/x86/x86_rtc.c
  28. 6
      cpu/x86/x86_threading.c
  29. 2
      drivers/at86rf231/at86rf231.c
  30. 8
      drivers/cc110x/cc1100_phy.c
  31. 4
      drivers/cc110x_ng/cc110x.c
  32. 2
      drivers/cc2420/cc2420.c
  33. 4
      drivers/include/at86rf231.h
  34. 5
      drivers/include/cc110x_ng/cc110x-interface.h
  35. 7
      drivers/include/cc2420.h
  36. 3
      drivers/include/rtc.h
  37. 6
      examples/ccn-lite-client/main.c
  38. 4
      examples/ccn-lite-relay/main.c
  39. 2
      examples/default/main.c
  40. 8
      examples/ipc_pingpong/main.c
  41. 2
      examples/rpl_udp/helper.c
  42. 11
      examples/rpl_udp/rpl.c
  43. 12
      examples/rpl_udp/udp.c
  44. 12
      sys/chardev_thread.c
  45. 3
      sys/include/board_uart0.h
  46. 7
      sys/include/fd.h
  47. 10
      sys/include/posix_io.h
  48. 11
      sys/include/transceiver.h
  49. 6
      sys/include/vtimer.h
  50. 6
      sys/net/ccn_lite/ccn-lite-relay.c
  51. 4
      sys/net/ccn_lite/ccnl-core.h
  52. 14
      sys/net/ccn_lite/ccnl-ext-appserver.c
  53. 4
      sys/net/ccn_lite/ccnl-riot-compat.c
  54. 12
      sys/net/ccn_lite/util/ccnl-riot-client.c
  55. 8
      sys/net/include/ccn_lite/util/ccnl-riot-client.h
  56. 2
      sys/net/include/net_if.h
  57. 6
      sys/net/include/sixlowpan/ip.h
  58. 2
      sys/net/include/sixlowpan/lowpan.h
  59. 2
      sys/net/include/sixlowpan/mac.h
  60. 2
      sys/net/link_layer/net_if/net_if.c
  61. 6
      sys/net/network_layer/sixlowpan/border/border.c
  62. 2
      sys/net/network_layer/sixlowpan/border/flowcontrol.c
  63. 2
      sys/net/network_layer/sixlowpan/icmp.h
  64. 22
      sys/net/network_layer/sixlowpan/ip.c
  65. 2
      sys/net/network_layer/sixlowpan/ip.h
  66. 10
      sys/net/network_layer/sixlowpan/lowpan.c
  67. 7
      sys/net/network_layer/sixlowpan/mac.c
  68. 6
      sys/net/routing/etx_beaconing.c
  69. 2
      sys/net/routing/rpl/rpl.c
  70. 2
      sys/net/routing/rpl/rpl.h
  71. 8
      sys/net/routing/rpl/trickle.c
  72. 4
      sys/net/transport_layer/destiny/destiny.c
  73. 4
      sys/net/transport_layer/destiny/msg_help.c
  74. 4
      sys/net/transport_layer/destiny/msg_help.h
  75. 12
      sys/net/transport_layer/destiny/socket.c
  76. 2
      sys/net/transport_layer/destiny/tcp.c
  77. 2
      sys/posix/fd.c
  78. 12
      sys/posix/posix_io.c
  79. 2
      sys/posix/pthread/include/pthread_barrier.h
  80. 12
      sys/posix/pthread/pthread.c
  81. 6
      sys/posix/pthread/pthread_barrier.c
  82. 34
      sys/posix/pthread/pthread_rwlock.c
  83. 2
      sys/ps/ps.c
  84. 12
      sys/transceiver/transceiver.c
  85. 4
      sys/uart0/uart0.c
  86. 6
      sys/vtimer/vtimer.c
  87. 6
      tests/ipc_pingpong/main.c
  88. 2
      tests/nativenet/main.c
  89. 20
      tests/posix_semaphore/main.c
  90. 10
      tests/pthread_condition_variable/main.c
  91. 2
      tests/pthread_rwlock/main.c
  92. 4
      tests/queue_fairness/main.c
  93. 6
      tests/thread_cooperation/main.c
  94. 10
      tests/thread_msg_block_w_queue/main.c
  95. 8
      tests/thread_msg_block_wo_queue/main.c
  96. 10
      tests/thread_msg_seq/main.c
  97. 8
      tests/vtimer_msg/main.c
  98. 4
      tests/vtimer_msg_diff/main.c

2
boards/avsextrem/drivers/avsextrem-smb380.c

@ -44,7 +44,7 @@
#include "lpc2387.h"
uint8_t simple_pid;
kernel_pid_t simple_pid;
int16_t simple_buffer[4];
volatile int16_t *ringBuff_X = NULL;

2
boards/msba2-common/drivers/include/uart0.h

@ -1,6 +1,6 @@
#ifndef __UART0_H
#define __UART0_H
extern int uart0_handler_pid;
extern kernel_pid_t uart0_handler_pid;
#endif /* __UART0_H */

4
core/include/kernel.h

@ -23,6 +23,7 @@
#define KERNEL_H_
#include <stdbool.h>
#include <stdint.h>
#include "attributes.h"
#include "config.h"
@ -66,12 +67,11 @@
#endif
/* ------------------------------------------------------------------------- */
/**
* @def PID_NULL
* @brief Identifier to detect an invalid PID
*/
#define PID_NULL -1
#define KERNEL_PID_NULL -1
/**
* @def PRIORITY_MIN

18
core/include/kernel_types.h

@ -0,0 +1,18 @@
#ifndef KERNEL_TYPES_H
#define KERNEL_TYPES_H
#include <stdint.h>
#include <inttypes.h>
/**
* Macro for printing formatter
*/
#define PRIkernel_pid PRIi16
/**
* @brief Unique process identifier
*
*/
typedef int16_t kernel_pid_t;
#endif /* KERNEL_TYPES_H */

9
core/include/msg.h

@ -34,6 +34,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "kernel_types.h"
/**
* @brief Describes a message object which can be sent between threads.
@ -44,7 +45,7 @@
*
*/
typedef struct msg {
uint16_t sender_pid; /**< PID of sending thread. Will be filled in
kernel_pid_t sender_pid; /**< PID of sending thread. Will be filled in
by msg_send. */
uint16_t type; /**< Type field. */
union {
@ -74,7 +75,7 @@ typedef struct msg {
* ``block == 0``
* @return -1, on error (invalid PID)
*/
int msg_send(msg_t *m, unsigned int target_pid, bool block);
int msg_send(msg_t *m, kernel_pid_t target_pid, bool block);
/**
@ -106,7 +107,7 @@ int msg_send_to_self(msg_t *m);
* @return 0, if receiver is not waiting and ``block == 0``
* @return -1, on error (invalid PID)
*/
int msg_send_int(msg_t *m, unsigned int target_pid);
int msg_send_int(msg_t *m, kernel_pid_t target_pid);
/**
@ -150,7 +151,7 @@ int msg_try_receive(msg_t *m);
*
* @return 1, if successful.
*/
int msg_send_receive(msg_t *m, msg_t *reply, unsigned int target_pid);
int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid);
/**
* @brief Replies to a message.

2
core/include/sched.h

@ -90,7 +90,7 @@ extern volatile int sched_num_threads;
/**
* Process ID of active thread
*/
extern volatile int sched_active_pid;
extern volatile kernel_pid_t sched_active_pid;
/**
* List of runqueues per priority level

2
core/include/tcb.h

@ -59,7 +59,7 @@ typedef struct tcb_t {
char *sp; /**< thread's stack pointer */
uint16_t status; /**< thread's status */
uint16_t pid; /**< thread's process id */
kernel_pid_t pid; /**< thread's process id */
uint16_t priority; /**< thread's priority */
clist_node_t rq_entry; /**< run queue entry */

10
core/include/thread.h

@ -72,7 +72,7 @@
* @return value ``<0`` on error
* @return pid of newly created task, otherwise
*/
int thread_create(char *stack,
kernel_pid_t thread_create(char *stack,
int stacksize,
char priority,
int flags,
@ -87,7 +87,7 @@ int thread_create(char *stack,
* @return status of the thread
* @return `STATUS_NOT_FOUND` if pid is unknown
*/
int thread_getstatus(int pid);
int thread_getstatus(kernel_pid_t pid);
/**
* @brief Returns the name of a process
@ -97,7 +97,7 @@ int thread_getstatus(int pid);
* @return the threads name
* @return `NULL` if pid is unknown
*/
const char *thread_getname(int pid);
const char *thread_getname(kernel_pid_t pid);
/**
* @brief Puts the current thread into sleep mode. Has to be woken up externally.
@ -120,7 +120,7 @@ void thread_yield(void);
* @return `1` on success
* @return `STATUS_NOT_FOUND` if pid is unknown or not sleeping
*/
int thread_wakeup(int pid);
int thread_wakeup(kernel_pid_t pid);
/**
@ -128,7 +128,7 @@ int thread_wakeup(int pid);
*
* @return obviously you are not a golfer.
*/
int thread_getpid(void);
kernel_pid_t thread_getpid(void);
/**
* @brief Measures the stack usage of a stack

20
core/msg.c

@ -51,13 +51,13 @@ static int queue_msg(tcb_t *target, msg_t *m)
return 0;
}
int msg_send(msg_t *m, unsigned int target_pid, bool block)
int msg_send(msg_t *m, kernel_pid_t target_pid, bool block)
{
if (inISR()) {
return msg_send_int(m, target_pid);
}
if ((unsigned int)sched_active_pid == target_pid) {
if (sched_active_pid == target_pid) {
return msg_send_to_self(m);
}
@ -73,12 +73,12 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block)
return -1;
}
DEBUG("msg_send() %s:%i: Sending from %i to %i. block=%i src->state=%i target->state=%i\n", __FILE__, __LINE__, sched_active_pid, target_pid, block, sched_active_thread->status, target->status);
DEBUG("msg_send() %s:%i: Sending from %" PRIkernel_pid " to %" PRIkernel_pid ". block=%i src->state=%i target->state=%i\n", __FILE__, __LINE__, sched_active_pid, target_pid, block, sched_active_thread->status, target->status);
if (target->status != STATUS_RECEIVE_BLOCKED) {
DEBUG("msg_send() %s:%i: Target %i is not RECEIVE_BLOCKED.\n", __FILE__, __LINE__, target_pid);
DEBUG("msg_send() %s:%i: Target %" PRIkernel_pid " is not RECEIVE_BLOCKED.\n", __FILE__, __LINE__, target_pid);
if (target->msg_array && queue_msg(target, m)) {
DEBUG("msg_send() %s:%i: Target %i has a msg_queue. Queueing message.\n", __FILE__, __LINE__, target_pid);
DEBUG("msg_send() %s:%i: Target %" PRIkernel_pid " has a msg_queue. Queueing message.\n", __FILE__, __LINE__, target_pid);
eINT();
if (sched_active_thread->status == STATUS_REPLY_BLOCKED) {
thread_yield();
@ -117,7 +117,7 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block)
DEBUG("msg_send: %s: Back from send block.\n", sched_active_thread->name);
}
else {
DEBUG("msg_send: %s: Direct msg copy from %i to %i.\n", sched_active_thread->name, thread_getpid(), target_pid);
DEBUG("msg_send: %s: Direct msg copy from %" PRIkernel_pid " to %" PRIkernel_pid ".\n", sched_active_thread->name, thread_getpid(), target_pid);
/* copy msg to target */
msg_t *target_message = (msg_t*) target->wait_data;
*target_message = *m;
@ -141,7 +141,7 @@ int msg_send_to_self(msg_t *m)
return res;
}
int msg_send_int(msg_t *m, unsigned int target_pid)
int msg_send_int(msg_t *m, kernel_pid_t target_pid)
{
tcb_t *target = (tcb_t *) sched_threads[target_pid];
@ -151,7 +151,7 @@ int msg_send_int(msg_t *m, unsigned int target_pid)
}
if (target->status == STATUS_RECEIVE_BLOCKED) {
DEBUG("msg_send_int: Direct msg copy from %i to %i.\n", thread_getpid(), target_pid);
DEBUG("msg_send_int: Direct msg copy from %" PRIkernel_pid " to %" PRIkernel_pid ".\n", thread_getpid(), target_pid);
m->sender_pid = target_pid;
@ -169,7 +169,7 @@ int msg_send_int(msg_t *m, unsigned int target_pid)
}
}
int msg_send_receive(msg_t *m, msg_t *reply, unsigned int target_pid)
int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid)
{
dINT();
tcb_t *me = (tcb_t*) sched_threads[sched_active_pid];
@ -188,7 +188,7 @@ int msg_reply(msg_t *m, msg_t *reply)
tcb_t *target = (tcb_t*) sched_threads[m->sender_pid];
if (!target) {
DEBUG("msg_reply(): %s: Target \"%" PRIu16 "\" not existing...dropping msg!\n", sched_active_thread->name, m->sender_pid);
DEBUG("msg_reply(): %s: Target \"%" PRIkernel_pid "\" not existing...dropping msg!\n", sched_active_thread->name, m->sender_pid);
return -1;
}

4
core/mutex.c

@ -84,7 +84,7 @@ static void mutex_wait(struct mutex_t *mutex)
void mutex_unlock(struct mutex_t *mutex)
{
DEBUG("%s: unlocking mutex. val: %u pid: %u\n", sched_active_thread->name, mutex->val, sched_active_pid);
DEBUG("%s: unlocking mutex. val: %u pid: %" PRIkernel_pid "\n", sched_active_thread->name, mutex->val, sched_active_pid);
int irqstate = disableIRQ();
if (mutex->val != 0) {
@ -106,7 +106,7 @@ void mutex_unlock(struct mutex_t *mutex)
void mutex_unlock_and_sleep(struct mutex_t *mutex)
{
DEBUG("%s: unlocking mutex. val: %u pid: %u, and taking a nap\n", sched_active_thread->name, mutex->val, sched_active_pid);
DEBUG("%s: unlocking mutex. val: %u pid: %" PRIkernel_pid ", and taking a nap\n", sched_active_thread->name, mutex->val, sched_active_pid);
int irqstate = disableIRQ();
if (mutex->val != 0) {

6
core/sched.c

@ -43,7 +43,7 @@ volatile unsigned int sched_context_switch_request;
volatile tcb_t *sched_threads[MAXTHREADS];
volatile tcb_t *sched_active_thread;
volatile int sched_active_pid = -1;
volatile kernel_pid_t sched_active_pid = KERNEL_PID_NULL;
clist_node_t *sched_runqueues[SCHED_PRIO_LEVELS];
static uint32_t runqueue_bitcache = 0;
@ -70,7 +70,7 @@ void sched_run(void)
#ifdef SCHED_TEST_STACK
if (*((unsigned int *)my_active_thread->stack_start) != (unsigned int) my_active_thread->stack_start) {
printf("scheduler(): stack overflow detected, task=%s pid=%u\n", my_active_thread->name, my_active_thread->pid);
printf("scheduler(): stack overflow detected, task=%s pid=%" PRIkernel_pid "\n", my_active_thread->name, my_active_thread->pid);
}
#endif
@ -92,7 +92,7 @@ void sched_run(void)
clist_advance(&(sched_runqueues[nextrq]));
my_active_thread = (tcb_t *)next.data;
int my_next_pid = my_active_thread->pid;
kernel_pid_t my_next_pid = my_active_thread->pid;
#if SCHEDSTATISTICS
sched_pidlist[my_next_pid].laststart = time;

16
core/thread.c

@ -32,12 +32,12 @@
#include "hwtimer.h"
#include "sched.h"
inline int thread_getpid(void)
inline kernel_pid_t thread_getpid(void)
{
return sched_active_thread->pid;
}
int thread_getstatus(int pid)
int thread_getstatus(kernel_pid_t pid)
{
if (sched_threads[pid] == NULL) {
return STATUS_NOT_FOUND;
@ -46,7 +46,7 @@ int thread_getstatus(int pid)
return sched_threads[pid]->status;
}
const char *thread_getname(int pid)
const char *thread_getname(kernel_pid_t pid)
{
if (sched_threads[pid] == NULL) {
return NULL;
@ -67,9 +67,9 @@ void thread_sleep(void)
thread_yield();
}
int thread_wakeup(int pid)
int thread_wakeup(kernel_pid_t pid)
{
DEBUG("thread_wakeup: Trying to wakeup PID %i...\n", pid);
DEBUG("thread_wakeup: Trying to wakeup PID %" PRIkernel_pid "...\n", pid);
int old_state = disableIRQ();
@ -106,7 +106,7 @@ int thread_measure_stack_free(char *stack)
return space_free;
}
int thread_create(char *stack, int stacksize, char priority, int flags, void *(*function)(void *arg), void *arg, const char *name)
kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags, void *(*function)(void *arg), void *arg, const char *name)
{
/* allocate our thread control block at the top of our stackspace */
int total_stacksize = stacksize;
@ -150,7 +150,7 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void *(*
dINT();
}
int pid = 0;
kernel_pid_t pid = 0;
while (pid < MAXTHREADS) {
if (sched_threads[pid] == NULL) {
@ -194,7 +194,7 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void *(*
sched_num_threads++;
DEBUG("Created thread %s. PID: %u. Priority: %u.\n", name, cb->pid, priority);
DEBUG("Created thread %s. PID: %" PRIkernel_pid ". Priority: %u.\n", name, cb->pid, priority);
if (flags & CREATE_SLEEPING) {
sched_set_status(cb, STATUS_SLEEPING);

1
cpu/arm_common/gettimeofday.c

@ -16,6 +16,7 @@
*/
#include <sys/time.h>
#include "kernel_types.h"
#if defined MODULE_RTC
# include "rtc.h"

4
cpu/arm_common/syscalls.c

@ -260,9 +260,9 @@ void _exit(int n)
while (1);
}
/*---------------------------------------------------------------------------*/
int _getpid(void)
pid_t _getpid(void)
{
return sched_active_thread->pid;
return (pid_t) sched_active_thread->pid;
}
/*---------------------------------------------------------------------------*/
int _kill_r(struct _reent *r, int pid, int sig)

2
cpu/cc430/cc430-rtc.c

@ -26,7 +26,7 @@ directory for more details.
//static volatile time_t epoch;
static struct tm time_to_set;
static int set_time = 0;
int rtc_second_pid = 0;
kernel_pid_t rtc_second_pid = 0;
/*---------------------------------------------------------------------------*/
void rtc_init(void)

2
cpu/cortex-m3_common/thread_arch.c

@ -107,7 +107,7 @@ void thread_arch_stack_print(void)
int count = 0;
uint32_t *sp = (uint32_t *)sched_active_thread->sp;
printf("printing the current stack of thread %u\n", thread_getpid());
printf("printing the current stack of thread %" PRIkernel_pid "\n", thread_getpid());
printf(" address: data:\n");
do {

2
cpu/lpc1768/syscalls.c

@ -219,7 +219,7 @@ void _exit(int n)
while(1);
}
/*---------------------------------------------------------------------------*/
int _getpid(void)
pid_t _getpid(void)
{
return sched_active_thread->pid;
}

2
cpu/lpc2387/rtc/lpc2387-rtc.c

@ -24,6 +24,8 @@ directory for more details.
#include <stdint.h>
#include <string.h>
#include "kernel_types.h"
/* cpu */
#include "VIC.h"
#include "lpc2387.h"

1
cpu/native/include/native_internal.h

@ -36,6 +36,7 @@
#endif
#endif // BSD/Linux
#include "kernel_types.h"
/**
* internal functions

4
cpu/native/include/nativenet.h

@ -27,6 +27,8 @@
#include <net/ethernet.h>
#include "kernel_types.h"
#define RX_BUF_SIZE (10)
#define TRANSCEIVER_BUFFER_SIZE (3)
@ -46,7 +48,7 @@
*
* @param transceiver_pid the pid of the transceiver thread
*/
void nativenet_init(int transceiver_pid);
void nativenet_init(kernel_pid_t transceiver_pid);
/**
* Shutdown transceiver

4
cpu/native/net/interface.c

@ -53,9 +53,9 @@ uint64_t _native_net_addr_long;
/* nativenet.h **********************************************************/
/************************************************************************/
void nativenet_init(int transceiver_pid)
void nativenet_init(kernel_pid_t transceiver_pid)
{
DEBUG("nativenet_init(transceiver_pid=%d)\n", transceiver_pid);
DEBUG("nativenet_init(transceiver_pid=%" PRIkernel_pid ")\n", transceiver_pid);
rx_buffer_next = 0;
_native_net_pan = 0;
_native_net_chan = 0;

1
cpu/native/syscalls.c

@ -34,6 +34,7 @@
#include <sys/time.h>
#endif
#include "kernel.h"
#include "cpu.h"
#include "irq.h"
#include "vtimer.h"

6
cpu/sam3x8e/syscalls.c

@ -97,9 +97,9 @@ caddr_t _sbrk_r(struct _reent *r, size_t incr)
*
* @return the process ID of the current thread
*/
int _getpid(void)
pid_t _getpid(void)
{
return sched_active_thread->pid;
return (pid_t) sched_active_thread->pid;
}
/**
@ -111,7 +111,7 @@ int _getpid(void)
*
* @return TODO
*/
int _kill_r(struct _reent *r, int pid, int sig)
int _kill_r(struct _reent *r, pid_t pid, int sig)
{
r->_errno = ESRCH; /* not implemented yet */
return -1;

12
cpu/x86/include/x86_rtc.h

@ -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, `-1u` to disable.
* @param target_pid The process which shall receive the message, `KERNEL_PID_NULL` 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)`,
@ -145,13 +145,13 @@ typedef void (*x86_rtc_callback_t)(uint8_t reg_c);
* You should not call this function directly.
* You should use hwtimer -- or better yet -- vtimer instead.
*/
bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, unsigned int target_pid, bool allow_replace);
bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace);
/**
* @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, `-1u` to disable.
* @param target_pid The process which shall receive the message, `KERNEL_PID_NULL` 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)`,
@ -160,12 +160,12 @@ bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, unsigne
* You should not call this function directly.
* You should use hwtimer -- or better yet -- vtimer instead.
*/
bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, unsigned int target_pid, bool allow_replace);
bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace);
/**
* @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, `-1u` to disable.
* @param target_pid The process which shall receive the message, `KERNEL_PID_NULL` 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)`,
@ -174,7 +174,7 @@ bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, unsigned int target_
* You should not call this function directly.
* You should use hwtimer -- or better yet -- vtimer instead.
*/
bool x86_rtc_set_update(uint32_t msg_content, unsigned int target_pid, bool allow_replace);
bool x86_rtc_set_update(uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace);
/**
* @brief Set custom alarm interrupt handler.

2
cpu/x86/x86_glue.c

@ -58,7 +58,7 @@ int close(int fildes)
pid_t getpid(void)
{
return sched_active_pid;
return (pid_t) sched_active_pid;
}
int fstat(int fildes, struct stat *buf)

10
cpu/x86/x86_hwtimer.c

@ -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, -1, false);
x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_NULL, 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, -1, false);
x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_NULL, 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, -1u, false);
x86_rtc_set_alarm(NULL, 0, KERNEL_PID_NULL, false);
}
if (rtc_update_ie) {
rtc_update_ie = 0;
x86_rtc_set_update(0, -1u, false);
x86_rtc_set_update(0, KERNEL_PID_NULL, false);
}
if (rtc_periodic_ie) {
rtc_periodic_ie = 0;
x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, -1u, false);
x86_rtc_set_periodic(RTC_REG_A_HZ_OFF, 0, KERNEL_PID_NULL, false);
}
}

34
cpu/x86/x86_rtc.c

@ -34,17 +34,19 @@
#include <stdio.h>
#include "kernel.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
static bool valid;
static int32_t alarm_msg_content, periodic_msg_content, update_msg_content;
static unsigned alarm_pid = -1u, periodic_pid = -1u, update_pid = -1u;
static unsigned alarm_pid = KERNEL_PID_NULL, periodic_pid = KERNEL_PID_NULL, update_pid = KERNEL_PID_NULL;
static void alarm_callback_default(uint8_t reg_c)
{
if (alarm_pid != -1u) {
if (alarm_pid != KERNEL_PID_NULL) {
msg_t m;
m.type = reg_c | (RTC_REG_B_INT_ALARM << 8);
m.content.value = alarm_msg_content;
@ -54,7 +56,7 @@ static void alarm_callback_default(uint8_t reg_c)
static void periodic_callback_default(uint8_t reg_c)
{
if (periodic_pid != -1u) {
if (periodic_pid != KERNEL_PID_NULL) {
msg_t m;
m.type = reg_c | (RTC_REG_B_INT_PERIODIC << 8);
m.content.value = periodic_msg_content;
@ -64,7 +66,7 @@ static void periodic_callback_default(uint8_t reg_c)
static void update_callback_default(uint8_t reg_c)
{
if (update_pid != -1u) {
if (update_pid != KERNEL_PID_NULL) {
msg_t m;
m.type = reg_c | (RTC_REG_B_INT_UPDATE << 8);
m.content.value = update_msg_content;
@ -196,7 +198,7 @@ bool x86_rtc_read(x86_rtc_data_t *dest)
return true;
}
bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, unsigned int target_pid, bool allow_replace)
bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace)
{
if (!valid) {
return false;
@ -204,15 +206,15 @@ bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, unsigne
unsigned old_status = disableIRQ();
bool result;
if (target_pid == -1u) {
if (target_pid == KERNEL_PID_NULL) {
result = true;
alarm_pid = -1u;
alarm_pid = KERNEL_PID_NULL;
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 == -1u;
result = allow_replace || alarm_pid == KERNEL_PID_NULL;
if (result) {
alarm_msg_content = msg_content;
alarm_pid = target_pid;
@ -236,7 +238,7 @@ bool x86_rtc_set_alarm(const x86_rtc_data_t *when, uint32_t msg_content, unsigne
return result;
}
bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, unsigned int target_pid, bool allow_replace)
bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace)
{
if (!valid) {
return false;
@ -244,16 +246,16 @@ bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, unsigned int target_
unsigned old_status = disableIRQ();
bool result;
if (target_pid == -1u || hz == RTC_REG_A_HZ_OFF) {
if (target_pid == KERNEL_PID_NULL || hz == RTC_REG_A_HZ_OFF) {
result = true;
periodic_pid = -1u;
periodic_pid = KERNEL_PID_NULL;
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 == -1u;
result = allow_replace || periodic_pid == KERNEL_PID_NULL;
if (result) {
periodic_msg_content = msg_content;
periodic_pid = target_pid;
@ -268,7 +270,7 @@ bool x86_rtc_set_periodic(uint8_t hz, uint32_t msg_content, unsigned int target_
return result;
}
bool x86_rtc_set_update(uint32_t msg_content, unsigned int target_pid, bool allow_replace)
bool x86_rtc_set_update(uint32_t msg_content, kernel_pid_t target_pid, bool allow_replace)
{
if (!valid) {
return false;
@ -276,14 +278,14 @@ bool x86_rtc_set_update(uint32_t msg_content, unsigned int target_pid, bool allo
unsigned old_status = disableIRQ();
bool result;
if (target_pid == -1u) {
if (target_pid == KERNEL_PID_NULL) {
result = true;
update_pid = -1u;
update_pid = KERNEL_PID_NULL;
x86_cmos_write(RTC_REG_B, x86_cmos_read(RTC_REG_B) & ~RTC_REG_B_INT_UPDATE);
}
else {
result = allow_replace || update_pid == -1u;
result = allow_replace || update_pid == KERNEL_PID_NULL;
if (result) {
update_msg_content = msg_content;
update_pid = target_pid;

6
cpu/x86/x86_threading.c

@ -51,7 +51,7 @@ static ucontext_t end_context;
bool x86_in_isr = true;
static long fpu_owner = -1;
static kernel_pid_t fpu_owner = KERNEL_PID_NULL;
//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 != -1) {
if (fpu_owner != KERNEL_PID_NULL) {
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 = -1;
fpu_owner = KERNEL_PID_NULL;
}
sched_task_exit();
}

2
drivers/at86rf231/at86rf231.c

@ -19,7 +19,7 @@ static uint8_t radio_channel;
static uint16_t radio_address;
static uint64_t radio_address_long;
void at86rf231_init(int tpid)
void at86rf231_init(kernel_pid_t tpid)
{
transceiver_pid = tpid;

8
drivers/cc110x/cc1100_phy.c

@ -82,11 +82,11 @@ static handler_entry_t handlers[MAX_PACKET_HANDLERS];
static const pm_table_t handler_table;
static const char *cc1100_event_handler_name = "cc1100_event_handler";
static mutex_t cc1100_mutex = MUTEX_INIT;
volatile int cc1100_mutex_pid;
volatile kernel_pid_t cc1100_mutex_pid;
static vtimer_t cc1100_watch_dog;
static timex_t cc1100_watch_dog_period;
static uint16_t cc1100_event_handler_pid;
static kernel_pid_t cc1100_event_handler_pid;
static void *cc1100_event_handler_function(void *);
static char event_handler_stack[KERNEL_CONF_STACKSIZE_MAIN];
@ -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 = -1;
cc1100_mutex_pid = KERNEL_PID_NULL;
/* 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 = -1;
cc1100_mutex_pid = KERNEL_PID_NULL;
mutex_unlock(&cc1100_mutex);
}

4
drivers/cc110x_ng/cc110x.c

@ -49,10 +49,10 @@ static void write_register(uint8_t r, uint8_t value);
/*---------------------------------------------------------------------------*
* Radio Driver API *
*---------------------------------------------------------------------------*/
void cc110x_init(int tpid)
void cc110x_init(kernel_pid_t tpid)
{
transceiver_pid = tpid;
DEBUG("Transceiver PID: %i\n", transceiver_pid);
DEBUG("Transceiver PID: %" PRIkernel_pid "\n", transceiver_pid);
rx_buffer_next = 0;

2
drivers/cc2420/cc2420.c

@ -74,7 +74,7 @@ void cc2420_initialize(void)
cc2420_switch_to_rx();
}
void cc2420_init(int tpid)
void cc2420_init(kernel_pid_t tpid)
{
transceiver_pid = tpid;
cc2420_initialize();

4
drivers/include/at86rf231.h

@ -28,9 +28,9 @@ typedef struct __attribute__((packed))
}
at86rf231_packet_t;
extern int transceiver_pid;
extern kernel_pid_t transceiver_pid;
void at86rf231_init(int tpid);
void at86rf231_init(kernel_pid_t tpid);
//void at86rf231_reset(void);
void at86rf231_rx(void);
void at86rf231_rx_handler(void);

5
drivers/include/cc110x_ng/cc110x-interface.h

@ -26,6 +26,7 @@
#include "radio/radio.h"
#include "radio/types.h"
#include "cc110x-config.h"
#include "kernel_types.h"
#define CC1100_MAX_DATA_LENGTH (58)
@ -115,9 +116,9 @@ extern volatile uint8_t rx_buffer_next; ///< Next packet in RX queue
extern volatile uint8_t radio_state; ///< Radio state
extern cc110x_statistic_t cc110x_statistic;
extern int transceiver_pid; ///< the transceiver thread pid
extern kernel_pid_t transceiver_pid; ///< the transceiver thread pid
void cc110x_init(int transceiver_pid);
void cc110x_init(kernel_pid_t transceiver_pid);
void cc110x_rx_handler(void);

7
drivers/include/cc2420.h

@ -80,6 +80,7 @@ Frame type value:
#include <stdbool.h>
#include "kernel_types.h"
#include "ieee802154_frame.h"
#include "cc2420_settings.h"
@ -106,8 +107,6 @@ typedef struct __attribute__ ((packed)) {
/* @} */
} cc2420_packet_t;
extern int transceiver_pid;
/**
* @brief Initialize the CC2420 transceiver.
*/
@ -119,7 +118,7 @@ void cc2420_initialize(void);
* @param[in] tpid The PID of the transceiver thread.
*/
void cc2420_init(int tpid);
void cc2420_init(kernel_pid_t tpid);
/**
* @brief Turn CC2420 on.
@ -362,7 +361,7 @@ int16_t cc2420_send(cc2420_packet_t *packet);
/**
* The PID of the transceiver thread.
*/
extern int transceiver_pid;
extern kernel_pid_t transceiver_pid;
/*
* RX Packet Buffer, read from the transceiver, filled by the cc2420_rx_handler.

3
drivers/include/rtc.h

@ -26,6 +26,7 @@ and Telematics group (http://cst.mi.fu-berlin.de).
#include <time.h>
#include <sys/time.h>
#include "kernel_types.h"
/**
* @brief Initializes the RTC for calendar mode
@ -60,7 +61,7 @@ void rtc_get_localtime(struct tm *localt);
*/
time_t rtc_time(struct timeval *time);
extern int rtc_second_pid;
extern kernel_pid_t rtc_second_pid;
/** @} */
#endif

6
examples/ccn-lite-client/main.c

@ -47,7 +47,7 @@ char relay_stack[KERNEL_CONF_STACKSIZE_MAIN];
#if RIOT_CCN_APPSERVER
char appserver_stack[KERNEL_CONF_STACKSIZE_MAIN];
#endif
int relay_pid, appserver_pid;
kernel_pid_t relay_pid, appserver_pid;
#define SHELL_MSG_BUFFER_SIZE (64)
msg_t msg_buffer_shell[SHELL_MSG_BUFFER_SIZE];
@ -73,7 +73,7 @@ static void riot_ccn_appserver(int argc, char **argv)
appserver_stack, sizeof(appserver_stack),
PRIORITY_MAIN - 1, CREATE_STACKTEST,
ccnl_riot_appserver_start, (void *) relay_pid, "appserver");
DEBUG("ccn-lite appserver on thread_id %d...\n", appserver_pid);
DEBUG("ccn-lite appserver on thread_id %" PRIkernel_pid "...\n", appserver_pid);
}
#endif
@ -183,7 +183,7 @@ static void riot_ccn_relay_start(void)
relay_stack, sizeof(relay_stack),
PRIORITY_MAIN - 2, CREATE_STACKTEST,
ccnl_riot_relay_start, NULL, "relay");
DEBUG("ccn-lite relay on thread_id %d...\n", relay_pid);
DEBUG("ccn-lite relay on thread_id %" PRIkernel_pid "...\n", relay_pid);
riot_ccn_transceiver_start(relay_pid);
}

4
examples/ccn-lite-relay/main.c

@ -31,7 +31,7 @@
// ccn
#include "ccn_lite/ccnl-riot.h"
int relay_pid;
kernel_pid_t relay_pid;
char t2_stack[KERNEL_CONF_STACKSIZE_MAIN];
@ -47,7 +47,7 @@ void set_address_handler(uint16_t a)
printf("trying to set address %" PRIu16 "\n", a);
mesg.type = SET_ADDRESS;
printf("transceiver_pid=%d\n", transceiver_pid);
printf("transceiver_pid=%" PRIkernel_pid"\n", transceiver_pid);
msg_send_receive(&mesg, &mesg, transceiver_pid);
printf("got address: %" PRIu16 "\n", a);

2
examples/default/main.c

@ -88,7 +88,7 @@ void *radio(void *arg)
void init_transceiver(void)
{
int radio_pid = thread_create(
kernel_pid_t radio_pid = thread_create(
radio_stack_buffer,
sizeof(radio_stack_buffer),
PRIORITY_MAIN - 2,

8
examples/ipc_pingpong/main.c

@ -28,12 +28,12 @@ void *second_thread(void *arg)
{
(void) arg;
printf("2nd thread started, pid: %i\n", thread_getpid());
printf("2nd thread started, pid: %" PRIkernel_pid "\n", thread_getpid());
msg_t m;
while (1) {
msg_receive(&m);
printf("2nd: Got msg from %i\n", m.sender_pid);
printf("2nd: Got msg from %" PRIkernel_pid "\n", m.sender_pid);
m.content.value++;
msg_reply(&m, &m);
}
@ -46,11 +46,11 @@ char second_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
int main(void)
{
printf("Starting IPC Ping-pong example...\n");
printf("1st thread started, pid: %i\n", thread_getpid());
printf("1st thread started, pid: %" PRIkernel_pid "\n", thread_getpid());
msg_t m;
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack),
kernel_pid_t pid = thread_create(second_thread_stack, sizeof(second_thread_stack),
PRIORITY_MAIN - 1, CREATE_STACKTEST,
second_thread, NULL, "pong");

2
examples/rpl_udp/helper.c

@ -137,7 +137,7 @@ void rpl_udp_ignore(int argc, char **argv)
if (argc == 2) {
a = atoi(argv[1]);
printf("sending to transceiver (%u): %u\n", transceiver_pid, (*(uint8_t *)tcmd.data));
printf("sending to transceiver (%" PRIkernel_pid "): %u\n", transceiver_pid, (*(uint8_t *)tcmd.data));
msg_send(&mesg, transceiver_pid, 1);
}
else {

11
examples/rpl_udp/rpl.c

@ -87,10 +87,13 @@ void rpl_udp_init(int argc, char **argv)
}
DEBUGF("Start monitor\n");
int monitor_pid = thread_create(
monitor_stack_buffer, sizeof(monitor_stack_buffer),
PRIORITY_MAIN - 2, CREATE_STACKTEST,
rpl_udp_monitor, NULL, "monitor");
kernel_pid_t monitor_pid = thread_create(monitor_stack_buffer,
sizeof(monitor_stack_buffer),
PRIORITY_MAIN - 2,
CREATE_STACKTEST,
rpl_udp_monitor,
NULL,
"monitor");
DEBUGF("Register at transceiver %02X\n", TRANSCEIVER);
transceiver_register(TRANSCEIVER, monitor_pid);
ipv6_register_packet_handler(monitor_pid);

12
examples/rpl_udp/udp.c

@ -46,11 +46,13 @@ void udp_server(int argc, char **argv)
(void) argc;
(void) argv;
int udp_server_thread_pid = thread_create(
udp_server_stack_buffer, sizeof(udp_server_stack_buffer),
PRIORITY_MAIN, CREATE_STACKTEST,
init_udp_server, NULL, "init_udp_server");
printf("UDP SERVER ON PORT %d (THREAD PID: %d)\n", HTONS(SERVER_PORT), udp_server_thread_pid);
kernel_pid_t udp_server_thread_pid = thread_create(udp_server_stack_buffer,
sizeof(udp_server_stack_buffer),
PRIORITY_MAIN, CREATE_STACKTEST,
init_udp_server,
NULL,
"init_udp_server");
printf("UDP SERVER ON PORT %d (THREAD PID: %" PRIkernel_pid ")\n", HTONS(SERVER_PORT), udp_server_thread_pid);
}
static void *init_udp_server(void *arg)

12
sys/chardev_thread.c

@ -45,9 +45,9 @@ void chardev_loop(ringbuffer_t *rb)
{
msg_t m;
int pid = thread_getpid();
kernel_pid_t pid = thread_getpid();
int reader_pid = -1;
kernel_pid_t reader_pid = KERNEL_PID_NULL;