sched: replace some global variables to macro

replace to macro will help to extend the scheduling implementation

Signed-off-by: chao an <anchao@lixiang.com>
This commit is contained in:
chao an
2024-03-20 12:22:08 +08:00
committed by Xiang Xiao
parent d90e1cb7b4
commit 4e62d0005a
14 changed files with 83 additions and 74 deletions

View File

@@ -136,13 +136,13 @@ static void exec_swap(FAR struct tcb_s *ptcb, FAR struct tcb_s *chtcb)
pndx = PIDHASH(ptcb->pid);
chndx = PIDHASH(chtcb->pid);
DEBUGASSERT(g_pidhash[pndx]);
DEBUGASSERT(g_pidhash[chndx]);
DEBUGASSERT(nxsched_pidhash()[pndx]);
DEBUGASSERT(nxsched_pidhash()[chndx]);
/* Exchange g_pidhash index */
/* Exchange nxsched_pidhash() index */
g_pidhash[pndx] = chtcb;
g_pidhash[chndx] = ptcb;
nxsched_pidhash()[pndx] = chtcb;
nxsched_pidhash()[chndx] = ptcb;
/* Exchange pid */

View File

@@ -187,9 +187,9 @@ static int elf_get_ntcb(void)
int count = 0;
int i;
for (i = 0; i < g_npidhash; i++)
for (i = 0; i < nxsched_npidhash(); i++)
{
if (g_pidhash[i] != NULL)
if (nxsched_pidhash()[i] != NULL)
{
count++;
}
@@ -313,11 +313,11 @@ static void elf_emit_note(FAR struct elf_dumpinfo_s *cinfo)
if (cinfo->pid == INVALID_PROCESS_ID)
{
for (i = 0; i < g_npidhash; i++)
for (i = 0; i < nxsched_npidhash(); i++)
{
if (g_pidhash[i] != NULL)
if (nxsched_pidhash()[i] != NULL)
{
elf_emit_tcb_note(cinfo, g_pidhash[i]);
elf_emit_tcb_note(cinfo, nxsched_pidhash()[i]);
}
}
}
@@ -395,11 +395,11 @@ static void elf_emit_stack(FAR struct elf_dumpinfo_s *cinfo)
if (cinfo->pid == INVALID_PROCESS_ID)
{
for (i = 0; i < g_npidhash; i++)
for (i = 0; i < nxsched_npidhash(); i++)
{
if (g_pidhash[i] != NULL)
if (nxsched_pidhash()[i] != NULL)
{
elf_emit_tcb_stack(cinfo, g_pidhash[i]);
elf_emit_tcb_stack(cinfo, nxsched_pidhash()[i]);
}
}
}
@@ -520,11 +520,11 @@ static void elf_emit_phdr(FAR struct elf_dumpinfo_s *cinfo,
if (cinfo->pid == INVALID_PROCESS_ID)
{
for (i = 0; i < g_npidhash; i++)
for (i = 0; i < nxsched_npidhash(); i++)
{
if (g_pidhash[i] != NULL)
if (nxsched_pidhash()[i] != NULL)
{
elf_emit_tcb_phdr(cinfo, g_pidhash[i], &phdr, &offset);
elf_emit_tcb_phdr(cinfo, nxsched_pidhash()[i], &phdr, &offset);
}
}
}