From 8200b51bd42e69333cbb3d50532bbd8b45201da2 Mon Sep 17 00:00:00 2001 From: bernie Date: Sun, 10 Aug 2008 20:19:14 +0000 Subject: [PATCH] proc_yield(): Rename from proc_switch() git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1620 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/drv/dataflash.c | 10 ++++------ bertos/drv/flash25.c | 8 ++++---- bertos/drv/ser.c | 24 +++++++++++------------- bertos/kern/coop.c | 2 +- bertos/kern/proc.h | 7 +++---- bertos/kern/proc_test.c | 5 ++--- 6 files changed, 25 insertions(+), 31 deletions(-) diff --git a/bertos/drv/dataflash.c b/bertos/drv/dataflash.c index a349895c..ac1eeaf5 100644 --- a/bertos/drv/dataflash.c +++ b/bertos/drv/dataflash.c @@ -55,7 +55,9 @@ #include #if CONFIG_KERNEL -#include + #include +#else + #define proc_yield() do {} while(0) #endif #include @@ -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); diff --git a/bertos/drv/flash25.c b/bertos/drv/flash25.c index 949ec401..807ff211 100644 --- a/bertos/drv/flash25.c +++ b/bertos/drv/flash25.c @@ -56,7 +56,9 @@ #include #if CONFIG_KERNEL -#include + #include +#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(); } } diff --git a/bertos/drv/ser.c b/bertos/drv/ser.c index 65a333da..5f2b6fcd 100644 --- a/bertos/drv/ser.c +++ b/bertos/drv/ser.c @@ -28,7 +28,6 @@ * * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/) * Copyright 2000 Bernie Innocenti - * * --> * * \brief Buffered serial I/O driver @@ -79,8 +78,10 @@ #error CONFIG_SER_DEFBAUDRATE missing in config.h #endif -#if CONFIG_KERNEL +#if CONFIG_KERNEL && CONFIG_KERN_SCHED #include +#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; diff --git a/bertos/kern/coop.c b/bertos/kern/coop.c index b62a02e4..f49f9dce 100644 --- a/bertos/kern/coop.c +++ b/bertos/kern/coop.c @@ -133,7 +133,7 @@ void proc_schedule(void) /** * Co-operative context switch */ -void proc_switch(void) +void proc_yield(void) { ATOMIC(SCHED_ENQUEUE(CurrentProcess)); diff --git a/bertos/kern/proc.h b/bertos/kern/proc.h index 0071ca13..50289a8a 100644 --- a/bertos/kern/proc.h +++ b/bertos/kern/proc.h @@ -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 diff --git a/bertos/kern/proc_test.c b/bertos/kern/proc_test.c index 38a6b16c..a32d667e 100644 --- a/bertos/kern/proc_test.c +++ b/bertos/kern/proc_test.c @@ -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; } -- 2.25.1