Updated comments; starting to implement priority protection but backed everything out but some changes to comments

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4510 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-03-23 20:14:21 +00:00
parent 52809cfca4
commit 98f6034444
13 changed files with 53 additions and 31 deletions

View File

@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec"> <h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i> <i>NuttX RTOS Porting Guide</i>
</font></big></h1> </font></big></h1>
<p>Last Updated: March 11, 2011</p> <p>Last Updated: March 23, 2011</p>
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -13,7 +13,7 @@
<h1><big><font color="#3c34ec"><i>NuttX Operating System<p>User's Manual</i></font></big></h1> <h1><big><font color="#3c34ec"><i>NuttX Operating System<p>User's Manual</i></font></big></h1>
<p><small>by</small></p> <p><small>by</small></p>
<p>Gregory Nutt<p> <p>Gregory Nutt<p>
<p>Last Updated: February 18, 2011</p> <p>Last Updated: March 23, 2012</p>
</td> </td>
</tr> </tr>
</table> </table>
@ -1838,7 +1838,7 @@ interface of the same name.
</li> </li>
</ul> </ul>
<p> <p>
POSIX semaphore interfaces: <b>POSIX semaphore interfaces:</b>
</p> </p>
<ul> <ul>
<li><a href="#seminit">2.5.1 sem_init</a></li> <li><a href="#seminit">2.5.1 sem_init</a></li>

View File

@ -314,6 +314,8 @@ defconfig -- This is a configuration file similar to the Linux
errorcheck mutexes. Enables pthread_mutexattr_settype(). errorcheck mutexes. Enables pthread_mutexattr_settype().
CONFIG_PRIORITY_INHERITANCE - Set to enable support for CONFIG_PRIORITY_INHERITANCE - Set to enable support for
priority inheritance on mutexes and semaphores. priority inheritance on mutexes and semaphores.
Priority inheritance is a strategy for addressing priority
inversion.
CONFIG_SEM_PREALLOCHOLDERS: This setting is only used if priority CONFIG_SEM_PREALLOCHOLDERS: This setting is only used if priority
inheritance is enabled. It defines the maximum number of inheritance is enabled. It defines the maximum number of
different threads (minus one) that can take counts on a different threads (minus one) that can take counts on a

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* include/semaphore.h * include/semaphore.h
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -33,8 +33,8 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef __SEMAPHORE_H #ifndef __INCLUDE_SEMAPHORE_H
#define __SEMAPHORE_H #define __INCLUDE_SEMAPHORE_H
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
@ -91,6 +91,8 @@ struct sem_s
}; };
typedef struct sem_s sem_t; typedef struct sem_s sem_t;
/* Initializers */
#ifdef CONFIG_PRIORITY_INHERITANCE #ifdef CONFIG_PRIORITY_INHERITANCE
# define SEM_INITIALIZER(c) {(c), SEMHOLDER_INITIALIZER} # define SEM_INITIALIZER(c) {(c), SEMHOLDER_INITIALIZER}
#else #else
@ -127,4 +129,4 @@ EXTERN int sem_getvalue(FAR sem_t *sem, FAR int *sval);
} }
#endif #endif
#endif /* __SEMAPHORE_H */ #endif /* __INCLUDE_SEMAPHORE_H */

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* lib/sem/sem_init.c * lib/sem/sem_init.c
* *
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -93,15 +93,24 @@
* *
****************************************************************************/ ****************************************************************************/
int sem_init (FAR sem_t *sem, int pshared, unsigned int value) int sem_init(FAR sem_t *sem, int pshared, unsigned int value)
{ {
/* Verify that a semaphore was provided and the count is within the valid
* range.
*/
if (sem && value <= SEM_VALUE_MAX) if (sem && value <= SEM_VALUE_MAX)
{ {
/* Initialize the seamphore count */
sem->semcount = (int16_t)value; sem->semcount = (int16_t)value;
/* Initialize to support priority inheritance */
#ifdef CONFIG_PRIORITY_INHERITANCE #ifdef CONFIG_PRIORITY_INHERITANCE
#if CONFIG_SEM_PREALLOCHOLDERS > 0 # if CONFIG_SEM_PREALLOCHOLDERS > 0
sem->hlist.flink = NULL; sem->hlist.flink = NULL;
#endif # endif
sem->hlist.holder = NULL; sem->hlist.holder = NULL;
sem->hlist.counts = 0; sem->hlist.counts = 0;
#endif #endif

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* sched/os_internal.h * sched/os_internal.h
* *
* Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* sched/sched_reprioritize.c * sched/sched_reprioritize.c
* *
* Copyright (C) 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* schec/sem_initialize.c * schec/sem_initialize.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* sched/sem_internal.h * sched/sem_internal.h
* *
* Copyright (C) 2007, 2009-2011 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -89,10 +89,16 @@ extern "C" {
#define EXTERN extern #define EXTERN extern
#endif #endif
/* Common semaphore logic */
EXTERN void weak_function sem_initialize(void); EXTERN void weak_function sem_initialize(void);
EXTERN void sem_waitirq(FAR _TCB *wtcb, int errcode); EXTERN void sem_waitirq(FAR _TCB *wtcb, int errcode);
EXTERN FAR nsem_t *sem_findnamed(const char *name); EXTERN FAR nsem_t *sem_findnamed(const char *name);
/* Special logic needed only by priority inheritance to manage collections of
* holders of semaphores.
*/
#ifdef CONFIG_PRIORITY_INHERITANCE #ifdef CONFIG_PRIORITY_INHERITANCE
EXTERN void sem_initholders(void); EXTERN void sem_initholders(void);
EXTERN void sem_destroyholder(FAR sem_t *sem); EXTERN void sem_destroyholder(FAR sem_t *sem);

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* sched/sem_post.c * sched/sem_post.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* sched/sem_wait.c * sched/sem_wait.c
* *
* Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* sched/task_restart.c * sched/task_restart.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -146,9 +146,12 @@ int task_restart(pid_t pid)
sig_cleanup(tcb); /* Deallocate Signal lists */ sig_cleanup(tcb); /* Deallocate Signal lists */
/* Reset the task priority */ /* Reset the current task priority */
tcb->sched_priority = tcb->init_priority; tcb->sched_priority = tcb->init_priority;
/* Reset the base task priority and the number of pending reprioritizations */
#ifdef CONFIG_PRIORITY_INHERITANCE #ifdef CONFIG_PRIORITY_INHERITANCE
tcb->base_priority = tcb->init_priority; tcb->base_priority = tcb->init_priority;
# if CONFIG_SEM_NNESTPRIO > 0 # if CONFIG_SEM_NNESTPRIO > 0

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* sched/task_setup.c * sched/task_setup.c
* *
* Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions