diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-03-23 20:14:21 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-03-23 20:14:21 +0000 |
commit | f054af6f3ae096c6851d8eae0d1d2e98bc631351 (patch) | |
tree | cff1dab1c7daaf9d6ba4d5aceaf5512e386bccf1 /nuttx/lib/semaphore | |
parent | 71e43504a2fb13b8b2a2e85f94815c2eadae20d4 (diff) | |
download | px4-nuttx-f054af6f3ae096c6851d8eae0d1d2e98bc631351.tar.gz px4-nuttx-f054af6f3ae096c6851d8eae0d1d2e98bc631351.tar.bz2 px4-nuttx-f054af6f3ae096c6851d8eae0d1d2e98bc631351.zip |
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
Diffstat (limited to 'nuttx/lib/semaphore')
-rw-r--r-- | nuttx/lib/semaphore/sem_init.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/nuttx/lib/semaphore/sem_init.c b/nuttx/lib/semaphore/sem_init.c index f90cc5470..ea1c6e84e 100644 --- a/nuttx/lib/semaphore/sem_init.c +++ b/nuttx/lib/semaphore/sem_init.c @@ -1,8 +1,8 @@ /**************************************************************************** * lib/sem/sem_init.c * - * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * 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) { + /* Initialize the seamphore count */ + sem->semcount = (int16_t)value; + + /* Initialize to support priority inheritance */ + #ifdef CONFIG_PRIORITY_INHERITANCE -#if CONFIG_SEM_PREALLOCHOLDERS > 0 +# if CONFIG_SEM_PREALLOCHOLDERS > 0 sem->hlist.flink = NULL; -#endif +# endif sem->hlist.holder = NULL; sem->hlist.counts = 0; #endif @@ -110,6 +119,6 @@ int sem_init (FAR sem_t *sem, int pshared, unsigned int value) else { set_errno(EINVAL); - return ERROR; + return ERROR; } } |