proc_yield(): Rename from proc_switch()
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Sun, 10 Aug 2008 20:19:14 +0000 (20:19 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Sun, 10 Aug 2008 20:19:14 +0000 (20:19 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1620 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/drv/dataflash.c
bertos/drv/flash25.c
bertos/drv/ser.c
bertos/kern/coop.c
bertos/kern/proc.h
bertos/kern/proc_test.c

index a349895c1d9044127478d3a33835179ab0132274..ac1eeaf551b72bc4de4167dd5920d7cc06a27194 100644 (file)
@@ -55,7 +55,9 @@
 #include <kern/kfile.h>
 
 #if CONFIG_KERNEL
-#include <kern/proc.h>
+       #include <kern/proc.h>
+#else
+       #define proc_yield() do {} while(0)
 #endif
 
 #include <string.h>
@@ -213,11 +215,7 @@ static uint8_t dataflash_cmd(DataFlash *fd, dataflash_page_t page_addr, dataflas
         * is high.
         */
        while (!(dataflash_stat(fd) & BUSY_BIT))
-       {
-               #if CONFIG_KERNEL
-               proc_switch();
-               #endif
-       }
+               proc_yield();
 
        stat = dataflash_stat(fd);
 
index 949ec4014e4ef9f6ee1438d0cf9531d35a6f2177..807ff2114286be9b8b94600224c19487352337b7 100644 (file)
@@ -56,7 +56,9 @@
 #include <kern/kfile.h>
 
 #if CONFIG_KERNEL
-#include <kern/proc.h>
+       #include <kern/proc.h>
+#else
+       #define proc_yield() do {} while(0)
 #endif
 
 #warning FIXME:This file was change, but is untest!
@@ -79,10 +81,8 @@ static void flash25_waitReady(Flash25 *fd)
 
                if (!(stat & RDY_BIT))
                        break;
-               #if CONFIG_KERNEL
                else
-                       proc_switch();
-               #endif
+                       proc_yield();
        }
 }
 
index 65a333daf746d21da6ee54fb19b8bc0583147c35..5f2b6fcd66af4298bdae8d95891c31276854ed57 100644 (file)
@@ -28,7 +28,6 @@
  *
  * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
  * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
  * -->
  *
  * \brief Buffered serial I/O driver
        #error CONFIG_SER_DEFBAUDRATE missing in config.h
 #endif
 
-#if CONFIG_KERNEL
+#if CONFIG_KERNEL && CONFIG_KERN_SCHED
        #include <kern/proc.h>
+#else
+       #define proc_yield() do {} while(0)
 #endif
 
 #if CONFIG_SER_TXTIMEOUT != -1 || CONFIG_SER_RXTIMEOUT != -1
@@ -113,11 +114,10 @@ static int ser_putchar(int c, struct Serial *port)
                /* Wait while buffer is full... */
                do
                {
-                       wdt_reset();
-#if CONFIG_KERNEL && CONFIG_KERN_SCHED
                        /* Give up timeslice to other processes. */
-                       proc_switch();
-#endif
+                       proc_yield();
+                       wdt_reset();
+
 #if CONFIG_SER_TXTIMEOUT != -1
                        if (timer_clock() - start_time >= port->txtimeout)
                        {
@@ -158,14 +158,14 @@ static int ser_getchar(struct Serial *port)
 
                ticks_t start_time = timer_clock();
 #endif
+
                /* Wait while buffer is empty */
                do
                {
-                       wdt_reset();
-#if CONFIG_KERNEL && CONFIG_KERN_SCHED
                        /* Give up timeslice to other processes. */
-                       proc_switch();
-#endif
+                       proc_yield();
+                       wdt_reset();
+
 #if CONFIG_SER_RXTIMEOUT != -1
                        if (timer_clock() - start_time >= port->rxtimeout)
                        {
@@ -355,10 +355,8 @@ static int ser_flush(struct KFile *fd)
        while (!fifo_isempty(&fds->txfifo)
               || fds->hw->table->txSending(fds->hw))
        {
-               #if CONFIG_KERNEL && CONFIG_KERN_SCHED
                        /* Give up timeslice to other processes. */
-                       proc_switch();
-               #endif
+                       proc_yield();
                        wdt_reset();
        }
        return 0;
index b62a02e43ddb0bedc48336e0675bbc1f81180617..f49f9dce7b1565ad9933195b7148a9b0c618850f 100644 (file)
@@ -133,7 +133,7 @@ void proc_schedule(void)
 /**
  * Co-operative context switch
  */
-void proc_switch(void)
+void proc_yield(void)
 {
        ATOMIC(SCHED_ENQUEUE(CurrentProcess));
 
index 0071ca13f41d3b779ab7630162598dae8aaaab55..50289a8a6adf8505defbade9ce4de7f951e2065a 100644 (file)
@@ -59,7 +59,9 @@ struct Process *proc_new_with_name(const char* name, void (*entry)(void), iptr_t
 #endif
 
 void proc_exit(void);
-void proc_switch(void);
+void proc_yield(void);
+#define proc_switch proc_yield /* OBSOLETE */
+
 int proc_testSetup(void);
 int proc_testRun(void);
 int proc_testTearDown(void);
@@ -117,9 +119,6 @@ void proc_rename(struct Process *proc, const char* name);
        #endif
 #endif
 
-/* OBSOLETE */
-#define CONFIG_KERN_DEFSTACKSIZE CONFIG_PROC_DEFSTACKSIZE
-
 /* Memory fill codes to help debugging */
 #if CONFIG_KERN_MONITOR
        #include <cpu/types.h>
index 38a6b16c66fe5083b9b41e1ce8c2ab95179a354a..a32d667e966edf9452013d596a5a693605527286 100644 (file)
@@ -50,7 +50,7 @@ static void proc_test1(void)
        {
                kputs("> test1\n");
                timer_delay(50);
-               proc_switch();
+               proc_yield();
        }
 }
 
@@ -63,7 +63,6 @@ static void proc_test2(void)
        {
                kputs("> test2\n");
                timer_delay(75);
-               proc_switch();
        }
 }
 
@@ -104,7 +103,7 @@ int proc_testRun(void)
        {
                kputs("> main\n");
                timer_delay(93);
-               proc_switch();
+               proc_yield();
        }
        return 0;
 }