diff options
author | Yonattan Louise <yonattan.a.louise.mendoza@intel.com> | 2015-05-14 16:30:48 -0500 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2016-02-05 20:13:59 -0500 |
commit | dbada63eee8516d35d11c1543788e742b70172e1 (patch) | |
tree | 6f6556441918eecadd2495e4e2944138422accf5 /samples/microkernel/apps/philosophers/src/phil_fiber.c | |
parent | d133f9661d670ca5340dd032ba3630f44d995af9 (diff) |
Fix coding style issues.
Some checkpatch issues were solved by scripts leaving other problems
such as alignment and indentation issues. In order to comply with the
defined coding style the following fixes were made:
- Fixed the function declaration moving the parameters' comments above
the function in accordance to the doxygen format.
- Fixed functions' opening and closing brackets. These brackets should
not be indented.
- Fixed the 'if', 'for' and 'while' statements adding the brackets
around the sentence.
- Fixed comments' alignment.
- Fixed indentation.
The work was done manually and submitted as one commit. I didn't
separate these changes in different commits because they were fixed all
at once. Basically, all errors were fixed in every file at once.
Change-Id: Icc94a10bfd2cff82007ce60df23b2ccd4c30268d
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
Diffstat (limited to 'samples/microkernel/apps/philosophers/src/phil_fiber.c')
-rw-r--r-- | samples/microkernel/apps/philosophers/src/phil_fiber.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/samples/microkernel/apps/philosophers/src/phil_fiber.c b/samples/microkernel/apps/philosophers/src/phil_fiber.c index 7d1fed633..1380766f5 100644 --- a/samples/microkernel/apps/philosophers/src/phil_fiber.c +++ b/samples/microkernel/apps/philosophers/src/phil_fiber.c @@ -71,30 +71,28 @@ kmutex_t forks[] = {forkMutex0, forkMutex1, forkMutex2, forkMutex3, forkMutex4, * * myPrint - print a philosophers state * +* @param id Philosopher ID. +* @param str EATING or THINKING. +* * RETURNS: N/A */ -static void myPrint - ( - int id, /* philosopher ID */ - char *str /* EATING or THINKING */ - ) - { +static void myPrint(int id, char *str) +{ PRINTF("\x1b[%d;%dHPhilosopher %d %s\n", id + 1, 1, id, str); - } +} /******************************************************************************* * * myDelay - wait for a number of ticks to elapse * +* @param ticks Number of ticks to delay. +* * RETURNS: N/A */ -static void myDelay - ( - int ticks /* # of ticks to delay */ - ) - { +static void myDelay(int ticks) +{ #ifdef CONFIG_MICROKERNEL task_sleep(ticks); #else @@ -104,7 +102,7 @@ static void myDelay nano_fiber_timer_start(&timer, ticks); nano_fiber_timer_wait(&timer); #endif - } +} /******************************************************************************* * @@ -117,7 +115,7 @@ static void myDelay */ void philEntry(void) - { +{ #ifdef CONFIG_NANOKERNEL struct nano_sem *f1; /* fork #1 */ struct nano_sem *f2; /* fork #2 */ @@ -125,33 +123,33 @@ void philEntry(void) kmutex_t f1; /* fork #1 */ kmutex_t f2; /* fork #2 */ #endif - static int myId; /* next philosopher ID */ - int pri = irq_lock(); /* interrupt lock level */ - int id = myId++; /* current philosopher ID */ + static int myId; /* next philosopher ID */ + int pri = irq_lock(); /* interrupt lock level */ + int id = myId++; /* current philosopher ID */ irq_unlock(pri); - /* always take the lowest fork first */ + /* always take the lowest fork first */ if ((id+1) != N_PHILOSOPHERS) { - f1 = FORK(id); - f2 = FORK(id + 1); + f1 = FORK(id); + f2 = FORK(id + 1); } else { - f1 = FORK(0); - f2 = FORK(id); + f1 = FORK(0); + f2 = FORK(id); } while (1) { - TAKE(f1); - TAKE(f2); + TAKE(f1); + TAKE(f2); PRINT(id, "EATING "); - RANDDELAY(id); + RANDDELAY(id); - GIVE(f2); - GIVE(f1); + GIVE(f2); + GIVE(f1); PRINT(id, "THINKING"); - RANDDELAY(id); - } + RANDDELAY(id); } +} |