From 3a57f9e2ef6cd84adc7b54aeab0643d174b55976 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 23 Jul 2015 10:15:57 -0600 Subject: [PATCH] Adjust for increased size of the scheduling policy field from 1 to 2 bits to allow additional, planned scheduling policies --- ChangeLog.txt | 2 ++ examples/thttpd/content/tasks/tasks.c | 13 +++++++++++-- nshlib/nsh_proccmds.c | 17 +++++++++++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 6ba58f527..8925a0e33 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1357,4 +1357,6 @@ anti-aliasing an option for each graphics call so you would rend the line with anti-aliasing ON and clear it with anti-aliasing OFF. but I don't have the wherewithal for that change today (2015-04-14)`. + * apps/nshlib and apps/examaples/thttpd: Change decoding to handle the + increased size of the scheduling policy field in the TCB (2015-07-23). diff --git a/examples/thttpd/content/tasks/tasks.c b/examples/thttpd/content/tasks/tasks.c index 198668519..3d6beb93e 100644 --- a/examples/thttpd/content/tasks/tasks.c +++ b/examples/thttpd/content/tasks/tasks.c @@ -85,6 +85,14 @@ static const char *g_ttypenames[4] = "--?-- " }; +static FAR const char *g_policynames[4] = +{ + "FIFO", + "RR ", + "SPOR", + "OTHR" +}; + /**************************************************************************** * Public Data ****************************************************************************/ @@ -105,13 +113,14 @@ static const char *g_ttypenames[4] = /* static */ void show_task(FAR struct tcb_s *tcb, FAR void *arg) { + FAR const char *policy; int i; /* Show task/thread status */ + policy = g_policynames[(tcb->flags & TCB_FLAG_POLICY_MASK) >> TCB_FLAG_POLICY_SHIFT]; printf("%5d %3d %4s %7s%c%c %8s ", - tcb->pid, tcb->sched_priority, - tcb->flags & TCB_FLAG_ROUND_ROBIN ? "RR " : "FIFO", + tcb->pid, tcb->sched_priority, policy, g_ttypenames[(tcb->flags & TCB_FLAG_TTYPE_MASK) >> TCB_FLAG_TTYPE_SHIFT], tcb->flags & TCB_FLAG_NONCANCELABLE ? 'N' : ' ', tcb->flags & TCB_FLAG_CANCEL_PENDING ? 'P' : ' ', diff --git a/nshlib/nsh_proccmds.c b/nshlib/nsh_proccmds.c index f436cc6af..43791c41e 100644 --- a/nshlib/nsh_proccmds.c +++ b/nshlib/nsh_proccmds.c @@ -1,7 +1,7 @@ /**************************************************************************** * apps/nshlib/nsh_proccmds.c * - * Copyright (C) 2007-2009, 2011-2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2012, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -108,6 +108,14 @@ static const char *g_ttypenames[4] = }; #endif +static FAR const char *g_policynames[4] = +{ + "FIFO", + "RR ", + "SPOR", + "OTHR" +}; + /**************************************************************************** * Public Data ****************************************************************************/ @@ -231,7 +239,8 @@ static int loadavg(pid_t pid, FAR char *buffer, size_t buflen) #ifndef CONFIG_NSH_DISABLE_PS static void ps_task(FAR struct tcb_s *tcb, FAR void *arg) { - struct nsh_vtbl_s *vtbl = (struct nsh_vtbl_s*)arg; + FAR struct nsh_vtbl_s *vtbl = (FAR struct nsh_vtbl_s*)arg; + FAR const char *policy; #ifdef HAVE_CPULOAD char buffer[8]; int ret; @@ -240,9 +249,9 @@ static void ps_task(FAR struct tcb_s *tcb, FAR void *arg) /* Show task status */ + policy = g_policynames[(tcb->flags & TCB_FLAG_POLICY_MASK) >> TCB_FLAG_POLICY_SHIFT]; nsh_output(vtbl, "%5d %3d %4s %7s%c%c %8s ", - tcb->pid, tcb->sched_priority, - tcb->flags & TCB_FLAG_ROUND_ROBIN ? "RR " : "FIFO", + tcb->pid, tcb->sched_priority, policy, g_ttypenames[(tcb->flags & TCB_FLAG_TTYPE_MASK) >> TCB_FLAG_TTYPE_SHIFT], tcb->flags & TCB_FLAG_NONCANCELABLE ? 'N' : ' ', tcb->flags & TCB_FLAG_CANCEL_PENDING ? 'P' : ' ',