Quellcode durchsuchen

Merge pull request #15 from misonyo/master

astyle codes
yqiu vor 7 Jahren
Ursprung
Commit
a2b005e03a
16 geänderte Dateien mit 271 neuen und 271 gelöschten Zeilen
  1. 10 10
      dynmem_sample.c
  2. 9 9
      event_sample.c
  3. 12 12
      idlehook_sample.c
  4. 10 10
      interrupt_sample.c
  5. 9 9
      mailbox_sample.c
  6. 9 9
      memp_sample.c
  7. 13 13
      msgq_sample.c
  8. 44 44
      mutex_sample.c
  9. 19 19
      priority_inversion.c
  10. 9 9
      producer_consumer.c
  11. 30 30
      scheduler_hook.c
  12. 28 28
      semaphore_sample.c
  13. 11 11
      signal_sample.c
  14. 11 11
      thread_sample.c
  15. 12 12
      timer_sample.c
  16. 35 35
      timeslice_sample.c

+ 10 - 10
dynmem_sample.c

@@ -1,13 +1,13 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
- 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
+
 /*
  * 程序清单:动态内存管理例程
  *

+ 9 - 9
event_sample.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:事件例程

+ 12 - 12
idlehook_sample.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */  
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:空闲任务钩子例程
@@ -56,7 +56,7 @@ static void thread_entry(void *parameter)
         rt_thread_mdelay(500);
     }
     rt_kprintf("delete idle hook.\n");
-    
+
     /* 删除空闲钩子函数 */
     rt_thread_idle_delhook(idle_hook);
     rt_kprintf("thread1 finish.\n");
@@ -69,8 +69,8 @@ int idle_hook_sample(void)
 
     /* 创建线程 */
     tid = rt_thread_create("thread1",
-                           thread_entry, RT_NULL, 
-                           THREAD_STACK_SIZE, 
+                           thread_entry, RT_NULL,
+                           THREAD_STACK_SIZE,
                            THREAD_PRIORITY, THREAD_TIMESLICE);
     if (tid != RT_NULL)
         rt_thread_startup(tid);

+ 10 - 10
interrupt_sample.c

@@ -1,13 +1,13 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
- 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
+
 /* 程序清单:关闭中断进行全局变量的访问 */
 #include <rthw.h>
 #include <rtthread.h>

+ 9 - 9
mailbox_sample.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:邮箱例程

+ 9 - 9
memp_sample.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:内存池例程

+ 13 - 13
msgq_sample.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:消息队列例程
@@ -61,9 +61,9 @@ static struct rt_thread thread2;
 static void thread2_entry(void *parameter)
 {
     int result;
-    char buf = 'A';    
+    char buf = 'A';
     rt_uint8_t cnt = 0;
-    
+
     while (1)
     {
         if (cnt == 8)
@@ -126,7 +126,7 @@ int msgq_sample(void)
                    thread1_entry,
                    RT_NULL,
                    &thread1_stack[0],
-                   sizeof(thread1_stack), 
+                   sizeof(thread1_stack),
                    THREAD_PRIORITY, THREAD_TIMESLICE);
     rt_thread_startup(&thread1);
 
@@ -135,7 +135,7 @@ int msgq_sample(void)
                    thread2_entry,
                    RT_NULL,
                    &thread2_stack[0],
-                   sizeof(thread2_stack), 
+                   sizeof(thread2_stack),
                    THREAD_PRIORITY, THREAD_TIMESLICE);
     rt_thread_startup(&thread2);
 

+ 44 - 44
mutex_sample.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:互斥锁例程
@@ -22,49 +22,49 @@
 
 /* 指向互斥量的指针 */
 static rt_mutex_t dynamic_mutex = RT_NULL;
-static rt_uint8_t number1,number2 = 0;
+static rt_uint8_t number1, number2 = 0;
 
 ALIGN(RT_ALIGN_SIZE)
 static char thread1_stack[1024];
 static struct rt_thread thread1;
 static void rt_thread_entry1(void *parameter)
 {
-      while(1)
-      {
-          /* 线程1获取到互斥量后,先后对number1、number2进行加1操作,然后释放互斥量 */
-          rt_mutex_take(dynamic_mutex, RT_WAITING_FOREVER);          
-          number1++;
-          rt_thread_mdelay(10);
-          number2++;          
-          rt_mutex_release(dynamic_mutex);
-       }	    
+    while (1)
+    {
+        /* 线程1获取到互斥量后,先后对number1、number2进行加1操作,然后释放互斥量 */
+        rt_mutex_take(dynamic_mutex, RT_WAITING_FOREVER);
+        number1++;
+        rt_thread_mdelay(10);
+        number2++;
+        rt_mutex_release(dynamic_mutex);
+    }
 }
 
 ALIGN(RT_ALIGN_SIZE)
 static char thread2_stack[1024];
 static struct rt_thread thread2;
 static void rt_thread_entry2(void *parameter)
-{     
-      while(1)
-      {
-          /* 线程2获取到互斥量后,检查number1、number2的值是否相同,相同则表示mutex起到了锁的作用 */
-          rt_mutex_take(dynamic_mutex, RT_WAITING_FOREVER);
-          if(number1 != number2)
-          {
-            rt_kprintf("not protect.number1 = %d, mumber2 = %d \n",number1 ,number2);
-          }
-          else
-          {
-            rt_kprintf("mutex protect ,number1 = mumber2 is %d\n",number1);            
-          }
-          
-           number1++;
-           number2++;
-           rt_mutex_release(dynamic_mutex);
-          
-          if(number1 >=50)
-              return;      
-      }	  
+{
+    while (1)
+    {
+        /* 线程2获取到互斥量后,检查number1、number2的值是否相同,相同则表示mutex起到了锁的作用 */
+        rt_mutex_take(dynamic_mutex, RT_WAITING_FOREVER);
+        if (number1 != number2)
+        {
+            rt_kprintf("not protect.number1 = %d, mumber2 = %d \n", number1, number2);
+        }
+        else
+        {
+            rt_kprintf("mutex protect ,number1 = mumber2 is %d\n", number1);
+        }
+
+        number1++;
+        number2++;
+        rt_mutex_release(dynamic_mutex);
+
+        if (number1 >= 50)
+            return;
+    }
 }
 
 /* 互斥量示例的初始化 */
@@ -83,17 +83,17 @@ int mutex_sample(void)
                    rt_thread_entry1,
                    RT_NULL,
                    &thread1_stack[0],
-                   sizeof(thread1_stack), 
+                   sizeof(thread1_stack),
                    THREAD_PRIORITY, THREAD_TIMESLICE);
     rt_thread_startup(&thread1);
-    
+
     rt_thread_init(&thread2,
                    "thread2",
                    rt_thread_entry2,
                    RT_NULL,
                    &thread2_stack[0],
-                   sizeof(thread2_stack), 
-                   THREAD_PRIORITY-1, THREAD_TIMESLICE);
+                   sizeof(thread2_stack),
+                   THREAD_PRIORITY - 1, THREAD_TIMESLICE);
     rt_thread_startup(&thread2);
     return 0;
 }

+ 19 - 19
priority_inversion.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:互斥量使用例程
@@ -112,27 +112,27 @@ int pri_inversion(void)
 
     /* 创建线程 1 */
     tid1 = rt_thread_create("thread1",
-                            thread1_entry, 
+                            thread1_entry,
                             RT_NULL,
-                            THREAD_STACK_SIZE, 
+                            THREAD_STACK_SIZE,
                             THREAD_PRIORITY - 1, THREAD_TIMESLICE);
     if (tid1 != RT_NULL)
-         rt_thread_startup(tid1);
- 
+        rt_thread_startup(tid1);
+
     /* 创建线程 2 */
     tid2 = rt_thread_create("thread2",
-                            thread2_entry, 
-                            RT_NULL, 
-                            THREAD_STACK_SIZE, 
+                            thread2_entry,
+                            RT_NULL,
+                            THREAD_STACK_SIZE,
                             THREAD_PRIORITY, THREAD_TIMESLICE);
     if (tid2 != RT_NULL)
         rt_thread_startup(tid2);
 
     /* 创建线程 3 */
     tid3 = rt_thread_create("thread3",
-                            thread3_entry, 
-                            RT_NULL, 
-                            THREAD_STACK_SIZE, 
+                            thread3_entry,
+                            RT_NULL,
+                            THREAD_STACK_SIZE,
                             THREAD_PRIORITY + 1, THREAD_TIMESLICE);
     if (tid3 != RT_NULL)
         rt_thread_startup(tid3);

+ 9 - 9
producer_consumer.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */  
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:生产者消费者例子

+ 30 - 30
scheduler_hook.c

@@ -1,29 +1,29 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
- 
- /*
- * 程序清单:调度器钩子
- * 在调度器钩子中打印线程切换信息
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
  */
 
+/*
+* 程序清单:调度器钩子
+* 在调度器钩子中打印线程切换信息
+*/
+
 #include <rtthread.h>
 
-#define THREAD_STACK_SIZE	1024
-#define THREAD_PRIORITY	    20
+#define THREAD_STACK_SIZE   1024
+#define THREAD_PRIORITY     20
 #define THREAD_TIMESLICE    10
 
 /* 针对每个线程的计数器 */
 volatile rt_uint32_t count[2];
 
 /* 线程1、2共用一个入口,但入口参数不同 */
-static void thread_entry(void* parameter)
+static void thread_entry(void *parameter)
 {
     rt_uint32_t value;
 
@@ -38,30 +38,30 @@ static void thread_entry(void* parameter)
 static rt_thread_t tid1 = RT_NULL;
 static rt_thread_t tid2 = RT_NULL;
 
-static void hook_of_scheduler(struct rt_thread* from, struct rt_thread* to)
+static void hook_of_scheduler(struct rt_thread *from, struct rt_thread *to)
 {
-    rt_kprintf("from: %s -->  to: %s \n", from->name , to->name);
+    rt_kprintf("from: %s -->  to: %s \n", from->name, to->name);
 }
 
 int scheduler_hook(void)
-{   
+{
     /* 设置调度器钩子 */
     rt_scheduler_sethook(hook_of_scheduler);
-    
+
     /* 创建线程1 */
-    tid1 = rt_thread_create("thread1", 
-                            thread_entry, (void*)1, 
-                            THREAD_STACK_SIZE, 
-                            THREAD_PRIORITY, THREAD_TIMESLICE); 
-    if (tid1 != RT_NULL) 
+    tid1 = rt_thread_create("thread1",
+                            thread_entry, (void *)1,
+                            THREAD_STACK_SIZE,
+                            THREAD_PRIORITY, THREAD_TIMESLICE);
+    if (tid1 != RT_NULL)
         rt_thread_startup(tid1);
 
     /* 创建线程2 */
-    tid2 = rt_thread_create("thread2", 
-                            thread_entry, (void*)2, 
-                            THREAD_STACK_SIZE, 
-                            THREAD_PRIORITY,THREAD_TIMESLICE - 5);
-    if (tid2 != RT_NULL) 
+    tid2 = rt_thread_create("thread2",
+                            thread_entry, (void *)2,
+                            THREAD_STACK_SIZE,
+                            THREAD_PRIORITY, THREAD_TIMESLICE - 5);
+    if (tid2 != RT_NULL)
         rt_thread_startup(tid2);
     return 0;
 }

+ 28 - 28
semaphore_sample.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:信号量例程
@@ -28,21 +28,21 @@ static struct rt_thread thread1;
 static void rt_thread1_entry(void *parameter)
 {
     static rt_uint8_t count = 0;
-  
-    while(1)
+
+    while (1)
     {
-        if(count <= 100)
+        if (count <= 100)
         {
-            count++;           
+            count++;
         }
         else
-            return; 
-        
+            return;
+
         /* count每计数10次,就释放一次信号量 */
-         if(0 == (count % 10))
+        if (0 == (count % 10))
         {
-            rt_kprintf("thread1 release a dynamic semaphore.\n" ); 
-            rt_sem_release(dynamic_sem);            
+            rt_kprintf("thread1 release a dynamic semaphore.\n");
+            rt_sem_release(dynamic_sem);
         }
     }
 }
@@ -54,22 +54,22 @@ static void rt_thread2_entry(void *parameter)
 {
     static rt_err_t result;
     static rt_uint8_t number = 0;
-    while(1)
+    while (1)
     {
         /* 永久方式等待信号量,获取到信号量,则执行number自加的操作 */
         result = rt_sem_take(dynamic_sem, RT_WAITING_FOREVER);
         if (result != RT_EOK)
-        {        
+        {
             rt_kprintf("thread2 take a dynamic semaphore, failed.\n");
             rt_sem_delete(dynamic_sem);
             return;
         }
         else
-        {      
-            number++;             
-            rt_kprintf("thread2 take a dynamic semaphore. number = %d\n" ,number);                        
+        {
+            number++;
+            rt_kprintf("thread2 take a dynamic semaphore. number = %d\n", number);
         }
-    }   
+    }
 }
 
 /* 信号量示例的初始化 */
@@ -92,17 +92,17 @@ int semaphore_sample()
                    rt_thread1_entry,
                    RT_NULL,
                    &thread1_stack[0],
-                   sizeof(thread1_stack), 
+                   sizeof(thread1_stack),
                    THREAD_PRIORITY, THREAD_TIMESLICE);
     rt_thread_startup(&thread1);
-                   
+
     rt_thread_init(&thread2,
                    "thread2",
                    rt_thread2_entry,
                    RT_NULL,
                    &thread2_stack[0],
-                   sizeof(thread2_stack), 
-                   THREAD_PRIORITY-1, THREAD_TIMESLICE);
+                   sizeof(thread2_stack),
+                   THREAD_PRIORITY - 1, THREAD_TIMESLICE);
     rt_thread_startup(&thread2);
 
     return 0;

+ 11 - 11
signal_sample.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:信号例程
@@ -56,8 +56,8 @@ int signal_sample(void)
                             thread1_entry, RT_NULL,
                             THREAD_STACK_SIZE,
                             THREAD_PRIORITY, THREAD_TIMESLICE);
-    
-    if (tid1 != RT_NULL)       
+
+    if (tid1 != RT_NULL)
         rt_thread_startup(tid1);
 
     rt_thread_mdelay(300);

+ 11 - 11
thread_sample.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
  * 程序清单:创建、初始化/脱离线程
@@ -51,7 +51,7 @@ static void thread2_entry(void *param)
         rt_kprintf("thread2 count: %d\n", count);
     }
     rt_kprintf("thread2 exit\n");
-	
+
     /* 线程2运行结束后也将自动被系统脱离 */
 }
 
@@ -63,7 +63,7 @@ int thread_sample(void)
                             thread1_entry, RT_NULL,
                             THREAD_STACK_SIZE,
                             THREAD_PRIORITY, THREAD_TIMESLICE);
-    
+
     /* 如果获得线程控制块,启动这个线程 */
     if (tid1 != RT_NULL)
         rt_thread_startup(tid1);

+ 12 - 12
timer_sample.c

@@ -1,12 +1,12 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
+ */
 
 /*
 * 程序清单:定时器例程
@@ -48,7 +48,7 @@ int timer_sample(void)
                              RT_TIMER_FLAG_PERIODIC);
 
     /* 启动定时器1 */
-    if (timer1 != RT_NULL) 
+    if (timer1 != RT_NULL)
         rt_timer_start(timer1);
 
     /* 创建定时器2 单次定时器 */
@@ -57,9 +57,9 @@ int timer_sample(void)
                              RT_TIMER_FLAG_ONE_SHOT);
 
     /* 启动定时器2 */
-    if (timer2 != RT_NULL) 
+    if (timer2 != RT_NULL)
         rt_timer_start(timer2);
-        
+
     return 0;
 }
 

+ 35 - 35
timeslice_sample.c

@@ -1,28 +1,28 @@
-/* 
- * Copyright (c) 2006-2018, RT-Thread Development Team 
- * 
- * SPDX-License-Identifier: Apache-2.0 
- * 
- * Change Logs: 
- * Date           Author       Notes 
- * 2018-08-24     yangjie      the first version 
- */ 
- 
- /*
- * 程序清单:相同优先级线程按照时间片轮转调度
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
  *
- * 这个例子中将创建两个线程,每一个线程都在打印信息
- * 
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-24     yangjie      the first version
  */
 
+/*
+* 程序清单:相同优先级线程按照时间片轮转调度
+*
+* 这个例子中将创建两个线程,每一个线程都在打印信息
+*
+*/
+
 #include <rtthread.h>
 
-#define THREAD_STACK_SIZE	1024
-#define THREAD_PRIORITY	    20
+#define THREAD_STACK_SIZE   1024
+#define THREAD_PRIORITY     20
 #define THREAD_TIMESLICE    10
 
 /* 线程入口 */
-static void thread_entry(void* parameter)
+static void thread_entry(void *parameter)
 {
     rt_uint32_t value;
     rt_uint32_t count = 0;
@@ -30,36 +30,36 @@ static void thread_entry(void* parameter)
     value = (rt_uint32_t)parameter;
     while (1)
     {
-        if(0 == (count % 5))
-        {           
-            rt_kprintf("thread %d is running ,thread %d count = %d\n", value , value , count);      
+        if (0 == (count % 5))
+        {
+            rt_kprintf("thread %d is running ,thread %d count = %d\n", value, value, count);
 
-            if(count > 200)
-                return;            
+            if (count > 200)
+                return;
         }
-         count++;
-     }  
+        count++;
+    }
 }
 
 int timeslice_sample(void)
 {
     rt_thread_t tid = RT_NULL;
     /* 创建线程1 */
-    tid = rt_thread_create("thread1", 
-                            thread_entry, (void*)1, 
-                            THREAD_STACK_SIZE, 
-                            THREAD_PRIORITY, THREAD_TIMESLICE); 
-    if (tid != RT_NULL) 
+    tid = rt_thread_create("thread1",
+                           thread_entry, (void *)1,
+                           THREAD_STACK_SIZE,
+                           THREAD_PRIORITY, THREAD_TIMESLICE);
+    if (tid != RT_NULL)
         rt_thread_startup(tid);
 
     /* 创建线程2 */
-    tid = rt_thread_create("thread2", 
-                            thread_entry, (void*)2,
-                            THREAD_STACK_SIZE, 
-                            THREAD_PRIORITY, THREAD_TIMESLICE-5);
-    if (tid != RT_NULL) 
+    tid = rt_thread_create("thread2",
+                           thread_entry, (void *)2,
+                           THREAD_STACK_SIZE,
+                           THREAD_PRIORITY, THREAD_TIMESLICE - 5);
+    if (tid != RT_NULL)
         rt_thread_startup(tid);
-        
+
     return 0;
 }