diff --git a/os/fs/procfs/fs_procfsproc.c b/os/fs/procfs/fs_procfsproc.c index 83d72b5c25..566ddcb741 100644 --- a/os/fs/procfs/fs_procfsproc.c +++ b/os/fs/procfs/fs_procfsproc.c @@ -412,7 +412,7 @@ static ssize_t proc_entry_stat(FAR struct proc_file_s *procfile, FAR struct tcb_ #ifdef CONFIG_SMP linesize = snprintf(procfile->line, STATUS_LINELEN, "%d %d %d %d %d %d %d %d %d %d", tcb->pid, ppid, tcb->sched_priority, tcb->flags, tcb->task_state, tcb->adj_stack_size, peak_stack, curr_heap, peak_heap, tcb->cpu); #else - linesize = snprintf(procfile->line, STATUS_LINELEN, "%d %d %d %d %d %d %d %d %d", tcb->pid, ppid, tcb->sched_priority, tcb->flags, tcb->task_state, tcb->adj_stack_size, peak_stack, curr_heap, peak_heap); + linesize = snprintf(procfile->line, STATUS_LINELEN, "%d %d %d %d %d %d %d %d %d %d", tcb->pid, ppid, tcb->sched_priority, tcb->flags, tcb->task_state, tcb->adj_stack_size, peak_stack, curr_heap, peak_heap, 0); #endif copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen, &offset); totalsize += copysize; diff --git a/os/include/sched.h b/os/include/sched.h index 176044d930..706c2887fe 100644 --- a/os/include/sched.h +++ b/os/include/sched.h @@ -431,6 +431,7 @@ int sched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask); int sched_cpucount(FAR const cpu_set_t *set); int sched_getcpu(void); #endif /* CONFIG_SMP */ +int sched_getcpucount(void); /* Task Switching Interfaces (non-standard) */ /** diff --git a/os/include/sys/syscall.h b/os/include/sys/syscall.h index 8144ef424a..bb81b80735 100644 --- a/os/include/sys/syscall.h +++ b/os/include/sys/syscall.h @@ -102,7 +102,8 @@ #define SYS_sched_getaffinity (CONFIG_SYS_RESERVED + 14) #define SYS_sched_setaffinity (CONFIG_SYS_RESERVED + 15) #define SYS_sched_getcpu (CONFIG_SYS_RESERVED + 16) -#define __SYS_sem (CONFIG_SYS_RESERVED + 17) +#define SYS_sched_getcpucount (CONFIG_SYS_RESERVED + 17) +#define __SYS_sem (CONFIG_SYS_RESERVED + 18) /* Semaphores */ diff --git a/os/include/tinyara/sched.h b/os/include/tinyara/sched.h index 309a1d5115..46b4a95d8f 100644 --- a/os/include/tinyara/sched.h +++ b/os/include/tinyara/sched.h @@ -219,9 +219,7 @@ enum tstate_e { TSTATE_TASK_INVALID = 0, /* INVALID - The TCB is uninitialized */ TSTATE_TASK_PENDING, /* READY_TO_RUN - Pending preemption unlock */ TSTATE_TASK_READYTORUN, /* READY-TO-RUN - But not running */ -#ifdef CONFIG_SMP TSTATE_TASK_ASSIGNED, /* READY-TO-RUN - Not running, but assigned to a CPU */ -#endif TSTATE_TASK_RUNNING, /* READY_TO_RUN - And running */ TSTATE_TASK_INACTIVE, /* BLOCKED - Initialized but not yet activated */ diff --git a/os/kernel/init/os_start.c b/os/kernel/init/os_start.c index 976ee8e151..012f837bb2 100644 --- a/os/kernel/init/os_start.c +++ b/os/kernel/init/os_start.c @@ -296,6 +296,10 @@ const struct tasklist_s g_tasklisttable[NUM_TASK_STATES] = &g_readytorun, TLIST_ATTR_PRIORITIZED | TLIST_ATTR_RUNNABLE }, + { /* TSTATE_TASK_ASSIGNED */ + &g_readytorun, + TLIST_ATTR_PRIORITIZED | TLIST_ATTR_RUNNABLE + }, { /* TSTATE_TASK_RUNNING */ &g_readytorun, TLIST_ATTR_PRIORITIZED | TLIST_ATTR_RUNNABLE diff --git a/os/kernel/sched/sched_getcpu.c b/os/kernel/sched/sched_getcpu.c index 19552d230f..3eb6c2cd1e 100644 --- a/os/kernel/sched/sched_getcpu.c +++ b/os/kernel/sched/sched_getcpu.c @@ -63,3 +63,8 @@ int sched_getcpu(void) { return up_cpu_index(); /* Does not fail */ } + +int sched_getcpucount(void) +{ + return CONFIG_SMP_NCPUS; +} diff --git a/os/syscall/syscall.csv b/os/syscall/syscall.csv index 13b94d1a2f..6749aad87c 100644 --- a/os/syscall/syscall.csv +++ b/os/syscall/syscall.csv @@ -103,6 +103,7 @@ "sched_getaffinity","sched.h","","int","pid_t","size_t","FAR cpu_set_t *" "sched_setaffinity","sched.h","","int","pid_t","size_t","FAR const cpu_set_t*" "sched_getcpu", "sched.h", "", "int" +"sched_getcpucount" , "sched.h", "", "int" "sched_getparam", "sched.h", "", "int", "pid_t", "struct sched_param*" "sched_getscheduler", "sched.h", "", "int", "pid_t" "sched_getstreams", "tinyara/sched.h", "CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0", "FAR struct streamlist*" diff --git a/os/syscall/syscall_lookup.h b/os/syscall/syscall_lookup.h index d8dfe55a89..78ba1ce205 100644 --- a/os/syscall/syscall_lookup.h +++ b/os/syscall/syscall_lookup.h @@ -78,6 +78,7 @@ SYSCALL_LOOKUP(set_errno, 1, STUB_set_errno) SYSCALL_LOOKUP(sched_getaffinity, 3, STUB_sched_getaffinity) SYSCALL_LOOKUP(sched_setaffinity, 3, STUB_sched_setaffinity) SYSCALL_LOOKUP(sched_getcpu, 0, STUB_sched_getcpu) +SYSCALL_LOOKUP(sched_getcpucount, 0, STUB_sched_getcpucount) /* Semaphores */ diff --git a/os/syscall/syscall_stublookup.c b/os/syscall/syscall_stublookup.c index 843f0323c2..e2ecd95c9d 100644 --- a/os/syscall/syscall_stublookup.c +++ b/os/syscall/syscall_stublookup.c @@ -94,10 +94,10 @@ uintptr_t STUB_sched_setscheduler(int nbr, uintptr_t parm1, uintptr_t parm2, int STUB_sched_getaffinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask); int STUB_sched_setaffinity(pid_t pid, size_t cpusetsize, FAR const cpu_set_t *mask); int STUB_sched_getcpu(void); +int STUB_sched_getcpucount(void); uintptr_t STUB_sched_unlock(int nbr); uintptr_t STUB_sched_yield(int nbr); - /* Semaphores */ uintptr_t STUB_sem_close(int nbr, uintptr_t parm1);