Skip to content

Commit

Permalink
pid_t: unify usage of special task IDs
Browse files Browse the repository at this point in the history
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
  • Loading branch information
pkarashchenko authored and xiaoxiang781216 committed Mar 22, 2022
1 parent 2ee12b2 commit 68902d8
Show file tree
Hide file tree
Showing 150 changed files with 359 additions and 456 deletions.
2 changes: 1 addition & 1 deletion arch/arm/include/cxd56xx/crashdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ typedef struct
fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */
int pid; /* Process ID */
pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stack_t stacks; /* Stack info */
#if CONFIG_TASK_NAME_SIZE > 0
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/arm/arm_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
tcb->stack_alloc_ptr = (void *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv6-m/arm_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
tcb->stack_alloc_ptr = (void *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-a/arm_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
tcb->stack_alloc_ptr = (void *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-m/arm_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
tcb->stack_alloc_ptr = (void *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-r/arm_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
tcb->stack_alloc_ptr = (void *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv8-m/arm_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
tcb->stack_alloc_ptr = (void *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
19 changes: 12 additions & 7 deletions arch/arm/src/cxd56xx/cxd56_cpu1signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <stdlib.h>
#include <errno.h>
#include <sched.h>
#include <nuttx/sched.h>
#include <nuttx/kthread.h>
#include <debug.h>

Expand Down Expand Up @@ -59,7 +60,7 @@ struct cxd56_sigtype_s

struct cxd56cpu1_info_s
{
int workerpid;
pid_t workerpid;
int ndev;
struct cxd56_sigtype_s sigtype[CXD56_CPU1_DATA_TYPE_MAX];
};
Expand All @@ -70,7 +71,11 @@ struct cxd56cpu1_info_s

static struct cxd56cpu1_info_s g_cpu1_info =
{
0
INVALID_PROCESS_ID,
0,
{
0
}
};

/****************************************************************************
Expand Down Expand Up @@ -193,9 +198,9 @@ int cxd56_cpu1siginit(uint8_t sigtype, FAR void *data)
}

pid = kthread_create("gnss_receiver",
CONFIG_CXD56CPU1_WORKER_THREAD_PRIORITY,
CONFIG_CXD56CPU1_WORKER_STACKSIZE, cxd56cpu1_worker,
(FAR char * const *) NULL);
CONFIG_CXD56CPU1_WORKER_THREAD_PRIORITY,
CONFIG_CXD56CPU1_WORKER_STACKSIZE, cxd56cpu1_worker,
(FAR char * const *) NULL);

if (pid < 0)
{
Expand All @@ -221,7 +226,7 @@ int cxd56_cpu1siginit(uint8_t sigtype, FAR void *data)
int cxd56_cpu1siguninit(uint8_t sigtype)
{
struct cxd56cpu1_info_s *priv = &g_cpu1_info;
int pid;
pid_t pid;
int ret;

if (sigtype >= CXD56_CPU1_DATA_TYPE_MAX)
Expand Down Expand Up @@ -249,7 +254,7 @@ int cxd56_cpu1siguninit(uint8_t sigtype)
}

pid = priv->workerpid;
priv->workerpid = 0;
priv->workerpid = INVALID_PROCESS_ID;

sched_unlock();

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/cxd56xx/cxd56_gnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ extern int fw_pm_sleepcpu(int cpuid, int mode);
struct cxd56_gnss_sig_s
{
uint8_t enable;
int pid;
pid_t pid;
FAR struct cxd56_gnss_signal_info_s info;
};

Expand Down Expand Up @@ -1466,7 +1466,7 @@ static int cxd56_gnss_set_signal(FAR struct file *filep, unsigned long arg)
FAR struct cxd56_gnss_signal_setting_s *setting;
FAR struct cxd56_gnss_sig_s *sig;
FAR struct cxd56_gnss_sig_s *checksig;
int pid;
pid_t pid;
int i;

if (!arg)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/cxd56xx/cxd56_icc.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct iccdev_s
/* for POSIX signal */

int signo;
int pid;
pid_t pid;
FAR void *sigdata;

struct sq_queue_s recvq;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/cxd56xx/cxd56_scu.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@
struct ev_notify_s
{
int signo; /* Signal number */
int pid; /* Target PID */
pid_t pid; /* Target PID */
struct scuev_arg_s *arg; /* Event argument */
struct scufifo_s *fifo; /* Reverse reference to FIFO */
};

struct wm_notify_s
{
int signo; /* Signal number */
int pid; /* Target PID */
pid_t pid; /* Target PID */
struct scutimestamp_s *ts; /* Event argument */
struct scufifo_s *fifo; /* Reverse reference to FIFO */
};
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/cxd56xx/cxd56_usbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ struct cxd56_usbdev_s
/* signal */

int signo;
int pid;
pid_t pid;
};

/* For maintaining tables of endpoint info */
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/rtl8720c/amebaz_depend.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ int rtw_create_task(struct task_struct *task, const char *name,
return pid;
}

wrap->pid = pid;
wrap->pid = (pid_t)pid;
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/rtl8720c/amebaz_depend.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct task_struct
};
struct nthread_wrapper
{
int pid;
pid_t pid;
thread_func_t func;
void *thctx;
};
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/tiva/common/tiva_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct tiva_canmod_s

/* kthread message handler thread ID */

int kthd_id;
pid_t kthd_id;

#ifdef CONFIG_CAN_ERRORS
/* Asynchronously report errors when status interrupts are disabled */
Expand Down Expand Up @@ -438,7 +438,7 @@ static int tivacan_setup(FAR struct can_dev_s *dev)
}
else
{
canmod->kthd_id = ret;
canmod->kthd_id = (pid_t)ret;
}

#ifdef CONFIG_CAN_EXTID
Expand Down
2 changes: 1 addition & 1 deletion arch/avr/src/avr/up_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
char *stack_ptr = (char *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/avr/src/avr32/up_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
char *stack_ptr = (char *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/ceva/src/common/up_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static void _up_assert(int errorcode)

/* Are we in an interrupt handler or the idle task? */

if (CURRENT_REGS || running_task()->pid == 0)
if (up_interrupt_context() || sched_idletask())
{
up_irq_save();
for (; ; )
Expand Down
2 changes: 1 addition & 1 deletion arch/ceva/src/xc5/up_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
tcb->stack_alloc_ptr = g_idle_basestack;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
Expand Down
2 changes: 1 addition & 1 deletion arch/ceva/src/xm6/up_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
tcb->stack_alloc_ptr = g_idle_basestack;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
Expand Down
2 changes: 1 addition & 1 deletion arch/hc/src/m9s12/m9s12_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
char *stack_ptr = (char *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/src/mips32/mips_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
char *stack_ptr = (char *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/misoc/src/lm32/lm32_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
char *stack_ptr = (char *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/misoc/src/minerva/minerva_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
char *stack_ptr = (char *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/or1k/src/common/up_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
tcb->stack_alloc_ptr = (void *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/renesas/src/m16c/m16c_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void up_initial_state(FAR struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
char *stack_ptr = (char *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/renesas/src/rx65n/rx65n_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
char *stack_ptr = (char *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/renesas/src/sh1/sh1_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
char *stack_ptr = (char *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
8 changes: 5 additions & 3 deletions arch/risc-v/src/bl602/bl602_os_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ int bl_os_task_create(const char *name,

void bl_os_task_delete(void *task_handle)
{
pid_t task = (int)task_handle;
pid_t pid = (pid_t)((uintptr_t)task_handle);

task_delete((pid_t)task);
task_delete(pid);
}

/****************************************************************************
Expand All @@ -358,7 +358,9 @@ void bl_os_task_delete(void *task_handle)

void *bl_os_task_get_current_task(void)
{
return (void *)0;
pid_t pid = getpid();

return (void *)((uintptr_t)pid);
}

/****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/riscv_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void up_initial_state(struct tcb_s *tcb)

/* Initialize the idle thread stack */

if (tcb->pid == 0)
if (tcb->pid == IDLE_PROCESS_ID)
{
tcb->stack_alloc_ptr = (void *)(g_idle_topstack -
CONFIG_IDLETHREAD_STACKSIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ static int32_t esp_task_create_pinned_to_core(void *entry,
wlerr("Failed to create task\n");
}

return pid > 0 ? true : false;
return pid > 0;
}

/****************************************************************************
Expand Down
Loading

0 comments on commit 68902d8

Please sign in to comment.