summaryrefslogtreecommitdiffstatsabout
path: root/SylixOS
diff options
context:
space:
mode:
authorHanhui <hanhui@acoinfo.com>2020-08-06 12:52:09 (GMT)
committer Hanhui <hanhui@acoinfo.com>2020-08-06 12:52:09 (GMT)
commit998fe90247d388655fc524738d56e60339b65da8 (patch)
tree413884bd994acf6baa5514e55e555275582ee4f8 /SylixOS
parent1a032f67f88c35f00084a82f6cc50a062dec9b18 (diff)
downloadlibsylixos-998fe90247d388655fc524738d56e60339b65da8.zip
libsylixos-998fe90247d388655fc524738d56e60339b65da8.tar.gz
libsylixos-998fe90247d388655fc524738d56e60339b65da8.tar.bz2
Separate the system time spinlock to improve the real-time performance.
Diffstat (limited to 'SylixOS')
-rw-r--r--SylixOS/arch/mips/common/mipsContext.c12
-rw-r--r--SylixOS/arch/ppc/common/ppcContext.c24
-rw-r--r--SylixOS/arch/riscv/common/riscvContext.c5
-rw-r--r--SylixOS/arch/sparc/common/sparcContext.c6
-rw-r--r--SylixOS/kernel/core/_GlobalInit.c1
-rw-r--r--SylixOS/kernel/core/_ITimerThread.c4
-rw-r--r--SylixOS/kernel/core/_RmsLib.c20
-rw-r--r--SylixOS/kernel/core/_SmpSpinlockKernel.c60
-rw-r--r--SylixOS/kernel/core/_UpSpinlockKernel.c46
-rw-r--r--SylixOS/kernel/core/_WakeupLine.c8
-rw-r--r--SylixOS/kernel/include/k_globalvar.h8
-rw-r--r--SylixOS/kernel/include/k_internal.h14
-rw-r--r--SylixOS/kernel/include/k_kernel.h4
-rw-r--r--SylixOS/kernel/include/k_spinlock.h32
-rw-r--r--SylixOS/kernel/interface/EventSetGet.c8
-rw-r--r--SylixOS/kernel/interface/KernelTicks.c8
-rw-r--r--SylixOS/kernel/interface/MsgQueueReceive.c4
-rw-r--r--SylixOS/kernel/interface/MsgQueueSend.c2
-rw-r--r--SylixOS/kernel/interface/MsgQueueSendEx.c2
-rw-r--r--SylixOS/kernel/interface/SemaphoreBPend.c2
-rw-r--r--SylixOS/kernel/interface/SemaphoreBPendEx.c2
-rw-r--r--SylixOS/kernel/interface/SemaphoreCPend.c2
-rw-r--r--SylixOS/kernel/interface/SemaphoreMPend.c2
-rw-r--r--SylixOS/kernel/interface/SemaphorePostPend.c4
-rw-r--r--SylixOS/kernel/interface/SemaphoreRWPend.c4
-rw-r--r--SylixOS/kernel/interface/TimeSleep.c10
-rw-r--r--SylixOS/kernel/interface/TimeTod.c8
-rw-r--r--SylixOS/lib/libc/time/lib_clock.c16
-rw-r--r--SylixOS/lib/libc/time/lib_time.c12
-rw-r--r--SylixOS/net/lwip/lwip_ifctl.c38
-rw-r--r--SylixOS/net/lwip/lwip_ifctl.h1
-rw-r--r--SylixOS/net/lwip/lwip_socket.c6
-rw-r--r--SylixOS/system/device/rand/randDevLib.c2
-rw-r--r--SylixOS/system/signal/signalLib.c8
34 files changed, 310 insertions, 75 deletions
diff --git a/SylixOS/arch/mips/common/mipsContext.c b/SylixOS/arch/mips/common/mipsContext.c
index 8fe0f52..65fe56a 100644
--- a/SylixOS/arch/mips/common/mipsContext.c
+++ b/SylixOS/arch/mips/common/mipsContext.c
@@ -60,10 +60,18 @@ PLW_STACK archTaskCtxCreate (ARCH_REG_CTX *pregctx,
ulCP0Status = mipsCp0StatusRead(); /* 获得当前的 CP0 STATUS 寄存器*/
ulCP0Status |= bspIntInitEnableStatus() | ST0_IE; /* 使能中断 */
ulCP0Status |= ST0_CU0; /* 使能 CU0 */
- ulCP0Status &= ~ST0_CU1; /* 禁能 CU1(FPU) */
+ if (ulOpt & LW_OPTION_THREAD_USED_FP) {
+ ulCP0Status |= ST0_CU1; /* 使能 CU1(FPU) */
+ } else {
+ ulCP0Status &= ~ST0_CU1; /* 禁能 CU1(FPU) */
+ }
ulCP0Status &= ~ST0_CU2; /* 禁能 CU2 */
ulCP0Status &= ~ST0_CU3; /* 禁能 CU3 */
- ulCP0Status &= ~ST0_MX; /* 禁能 MDMX ASE 或 DSP */
+ if (ulOpt & LW_OPTION_THREAD_USED_DSP) {
+ ulCP0Status |= ST0_MX; /* 使能 MDMX ASE 或 DSP */
+ } else {
+ ulCP0Status &= ~ST0_MX; /* 禁能 MDMX ASE 或 DSP */
+ }
pstkTop = (PLW_STACK)ROUND_DOWN(pstkTop, ARCH_STK_ALIGN_SIZE); /* 保证出栈后 SP 8/16 字节对齐 */
diff --git a/SylixOS/arch/ppc/common/ppcContext.c b/SylixOS/arch/ppc/common/ppcContext.c
index bc622af..9cef633 100644
--- a/SylixOS/arch/ppc/common/ppcContext.c
+++ b/SylixOS/arch/ppc/common/ppcContext.c
@@ -56,8 +56,16 @@ PLW_STACK archTaskCtxCreate (ARCH_REG_CTX *pregctx,
uiMsr |= ARCH_PPC_MSR_EE; /* 使能中断 */
uiMsr &= ~ARCH_PPC_MSR_PR; /* 特权模式 */
- uiMsr &= ~ARCH_PPC_MSR_FP; /* 禁能 FPU */
- uiMsr &= ~ARCH_PPC_MSR_VEC; /* 禁能 ALTIVEC */
+ if (ulOpt & LW_OPTION_THREAD_USED_FP) {
+ uiMsr |= ARCH_PPC_MSR_FP; /* 使能 FPU */
+ } else {
+ uiMsr &= ~ARCH_PPC_MSR_FP; /* 禁能 FPU */
+ }
+ if (ulOpt & LW_OPTION_THREAD_USED_DSP) {
+ uiMsr |= ARCH_PPC_MSR_VEC; /* 使能 ALTIVEC */
+ } else {
+ uiMsr &= ~ARCH_PPC_MSR_VEC; /* 禁能 ALTIVEC */
+ }
#if LW_CFG_VMM_EN > 0
uiMsr |= ARCH_PPC_MSR_IR | ARCH_PPC_MSR_DR; /* 使能 MMU */
#else
@@ -71,8 +79,16 @@ PLW_STACK archTaskCtxCreate (ARCH_REG_CTX *pregctx,
#define ARCH_PPC_MSR_DS 0x00000010 /* data address space selector */
uiMsr |= ARCH_PPC_MSR_EE; /* 使能中断 */
- uiMsr &= ~ARCH_PPC_MSR_FP; /* 禁能 FPU(E500mc E5500 E6500)*/
- uiMsr &= ~ARCH_PPC_MSR_SPE; /* 禁能 SPE(E6500 时为 ALTIVEC)*/
+ if (ulOpt & LW_OPTION_THREAD_USED_FP) {
+ uiMsr |= ARCH_PPC_MSR_FP; /* 使能 FPU(E500mc E5500 E6500)*/
+ } else {
+ uiMsr &= ~ARCH_PPC_MSR_FP; /* 禁能 FPU(E500mc E5500 E6500)*/
+ }
+ if (ulOpt & LW_OPTION_THREAD_USED_DSP) {
+ uiMsr |= ARCH_PPC_MSR_SPE; /* 使能 SPE(E6500 时为 ALTIVEC)*/
+ } else {
+ uiMsr &= ~ARCH_PPC_MSR_SPE; /* 禁能 SPE(E6500 时为 ALTIVEC)*/
+ }
uiMsr &= ~(ARCH_PPC_MSR_IS | ARCH_PPC_MSR_DS); /* 使用地址空间 0 */
#undef ARCH_PPC_MSR_SPE
diff --git a/SylixOS/arch/riscv/common/riscvContext.c b/SylixOS/arch/riscv/common/riscvContext.c
index d51473e..e37cf6b 100644
--- a/SylixOS/arch/riscv/common/riscvContext.c
+++ b/SylixOS/arch/riscv/common/riscvContext.c
@@ -62,6 +62,11 @@ PLW_STACK archTaskCtxCreate (ARCH_REG_CTX *pregctx,
pregctx->REG_ulSmallCtx = 1; /* 小上下文 */
pregctx->REG_ulStatus = XSTATUS_XPP | XSTATUS_XPIE;
+ if (ulOpt & LW_OPTION_THREAD_USED_FP) {
+ pregctx->REG_ulStatus |= XSTATUS_FS; /* 使能 FPU */
+ } else {
+ pregctx->REG_ulStatus &= ~XSTATUS_FS; /* 禁能 FPU */
+ }
pregctx->REG_ulTrapVal = 0;
pregctx->REG_ulCause = 0;
pregctx->REG_ulEpc = (ARCH_REG_T)pfuncTask;
diff --git a/SylixOS/arch/sparc/common/sparcContext.c b/SylixOS/arch/sparc/common/sparcContext.c
index 500f295..3f1a3e2 100644
--- a/SylixOS/arch/sparc/common/sparcContext.c
+++ b/SylixOS/arch/sparc/common/sparcContext.c
@@ -92,7 +92,11 @@ PLW_STACK archTaskCtxCreate (ARCH_REG_CTX *pregctx,
uiPsr = archPsrGet();
uiPsr &= ~PSR_PIL; /* 使能中断 */
uiPsr &= ~PSR_CWP; /* 使用窗口 0 */
- uiPsr &= ~PSR_EF; /* 禁能浮点 */
+ if (ulOpt & LW_OPTION_THREAD_USED_FP) {
+ uiPsr |= PSR_EF; /* 使能 FPU */
+ } else {
+ uiPsr &= ~PSR_EF; /* 禁能 FPU */
+ }
uiPsr &= ~PSR_EC; /* 禁能协处理器 */
uiPsr |= PSR_S | PSR_PS; /* 特权模式 */
uiPsr |= PSR_ET; /* 使能异常 */
diff --git a/SylixOS/kernel/core/_GlobalInit.c b/SylixOS/kernel/core/_GlobalInit.c
index 3b37c31..a82b0db 100644
--- a/SylixOS/kernel/core/_GlobalInit.c
+++ b/SylixOS/kernel/core/_GlobalInit.c
@@ -223,6 +223,7 @@ VOID _GlobalPrimaryInit (VOID)
* 内核关键性自旋锁初始化
*/
LW_SPIN_INIT(&_K_klKernel.KERN_slLock); /* 初始化内核自旋锁 */
+ LW_SPIN_INIT(&_K_slKernTime.SLCA_sl); /* 初始化内核时间自旋锁 */
LW_SPIN_INIT(&_K_slcaAtomic.SLCA_sl); /* 初始化原子操作自旋锁 */
/*
diff --git a/SylixOS/kernel/core/_ITimerThread.c b/SylixOS/kernel/core/_ITimerThread.c
index 4488943..22489cf 100644
--- a/SylixOS/kernel/core/_ITimerThread.c
+++ b/SylixOS/kernel/core/_ITimerThread.c
@@ -63,7 +63,7 @@ PVOID _ITimerThread (PVOID pvArg)
for (;;) {
iregInterLevel = __KERNEL_ENTER_IRQ(); /* 进入内核同时关闭中断 */
- __KERNEL_TIME_GET_NO_SPINLOCK(_K_wuITmr.WU_i64LastTime, INT64); /* 原始时间 */
+ __KERNEL_TIME_GET_IGNIRQ(_K_wuITmr.WU_i64LastTime, INT64); /* 原始时间 */
__WAKEUP_GET_FIRST(&_K_wuITmr, pwun); /* 获得第一个节点 */
@@ -91,7 +91,7 @@ PVOID _ITimerThread (PVOID pvArg)
continue;
}
- __KERNEL_TIME_GET_NO_SPINLOCK(i64CurTime, INT64); /* 获得 Sleep 后时间 */
+ __KERNEL_TIME_GET_IGNIRQ(i64CurTime, INT64); /* 获得 Sleep 后时间 */
ulCounter = (ULONG)(i64CurTime - _K_wuITmr.WU_i64LastTime); /* 真正睡眠时间 */
_K_wuITmr.WU_i64LastTime = i64CurTime;
diff --git a/SylixOS/kernel/core/_RmsLib.c b/SylixOS/kernel/core/_RmsLib.c
index ac41750..afdadcc 100644
--- a/SylixOS/kernel/core/_RmsLib.c
+++ b/SylixOS/kernel/core/_RmsLib.c
@@ -29,7 +29,7 @@
#include "../SylixOS/kernel/include/k_kernel.h"
/*********************************************************************************************************
** 函数名称: _RmsActive
-** 功能描述: 第一次激活 RMS 并开始对线程执行时间进行测量 (进入内核后被调用)
+** 功能描述: 第一次激活 RMS 并开始对线程执行时间进行测量 (进入内核并关中断后被调用)
** 输 入 :
** 输 出 :
** 全局变量:
@@ -40,11 +40,11 @@
VOID _RmsActive (PLW_CLASS_RMS prms)
{
prms->RMS_ucStatus = LW_RMS_ACTIVE;
- __KERNEL_TIME_GET_NO_SPINLOCK(prms->RMS_ulTickSave, ULONG);
+ __KERNEL_TIME_GET_IGNIRQ(prms->RMS_ulTickSave, ULONG);
}
/*********************************************************************************************************
** 函数名称: _RmsGetExecTime
-** 功能描述: 计算任务执行的时间 (进入内核后被调用)
+** 功能描述: 计算任务执行的时间 (进入内核并关中断后被调用)
** 输 入 :
** 输 出 :
** 全局变量:
@@ -55,7 +55,7 @@ ULONG _RmsGetExecTime (PLW_CLASS_RMS prms)
REGISTER ULONG ulThreadExecTime;
ULONG ulKernelTime;
- __KERNEL_TIME_GET_NO_SPINLOCK(ulKernelTime, ULONG);
+ __KERNEL_TIME_GET_IGNIRQ(ulKernelTime, ULONG);
ulThreadExecTime = (ulKernelTime >= prms->RMS_ulTickSave) ?
(ulKernelTime - prms->RMS_ulTickSave) :
(ulKernelTime + (__ARCH_ULONG_MAX - prms->RMS_ulTickSave) + 1);
@@ -64,7 +64,7 @@ ULONG _RmsGetExecTime (PLW_CLASS_RMS prms)
}
/*********************************************************************************************************
** 函数名称: _RmsInitExpire
-** 功能描述: 开始进行时间等待 (进入内核后被调用)
+** 功能描述: 开始进行时间等待 (进入内核并关中断后被调用)
** 输 入 :
** 输 出 :
** 全局变量:
@@ -78,19 +78,19 @@ ULONG _RmsInitExpire (PLW_CLASS_RMS prms, ULONG ulPeriod, ULONG *pulWaitTick
LW_TCB_GET_CUR(ptcbCur);
- __KERNEL_TIME_GET_NO_SPINLOCK(ulKernelTime, ULONG);
+ __KERNEL_TIME_GET_IGNIRQ(ulKernelTime, ULONG);
ulThreadExecTime = (ulKernelTime >= prms->RMS_ulTickSave) ?
(ulKernelTime - prms->RMS_ulTickSave) :
(ulKernelTime + (__ARCH_ULONG_MAX - prms->RMS_ulTickSave) + 1);
if (ulThreadExecTime > ulPeriod) {
- __KERNEL_TIME_GET_NO_SPINLOCK(prms->RMS_ulTickSave, ULONG); /* 重新记录系统时钟 */
+ __KERNEL_TIME_GET_IGNIRQ(prms->RMS_ulTickSave, ULONG); /* 重新记录系统时钟 */
return (ERROR_RMS_TICK);
}
if (ulThreadExecTime == ulPeriod) {
*pulWaitTick = 0;
- __KERNEL_TIME_GET_NO_SPINLOCK(prms->RMS_ulTickSave, ULONG); /* 重新记录系统时钟 */
+ __KERNEL_TIME_GET_IGNIRQ(prms->RMS_ulTickSave, ULONG); /* 重新记录系统时钟 */
return (ERROR_NONE);
}
@@ -99,7 +99,7 @@ ULONG _RmsInitExpire (PLW_CLASS_RMS prms, ULONG ulPeriod, ULONG *pulWaitTick
prms->RMS_ucStatus = LW_RMS_EXPIRED; /* 改变状态 */
prms->RMS_ptcbOwner = ptcbCur; /* 记录当前TCB */
- __KERNEL_TIME_GET_NO_SPINLOCK(prms->RMS_ulTickNext, ULONG);
+ __KERNEL_TIME_GET_IGNIRQ(prms->RMS_ulTickNext, ULONG);
prms->RMS_ulTickNext += *pulWaitTick; /* 计算下次到时时间 */
/* 自然溢出 */
@@ -120,7 +120,7 @@ ULONG _RmsEndExpire (PLW_CLASS_RMS prms)
}
prms->RMS_ucStatus = LW_RMS_ACTIVE; /* 改变状态 */
- __KERNEL_TIME_GET_NO_SPINLOCK(prms->RMS_ulTickSave, ULONG); /* 重新记录系统时钟 */
+ __KERNEL_TIME_GET(prms->RMS_ulTickSave, ULONG); /* 重新记录系统时钟 */
if (prms->RMS_ulTickNext != prms->RMS_ulTickSave) { /* 是否 TIME OUT */
return (ERROR_THREAD_WAIT_TIMEOUT);
diff --git a/SylixOS/kernel/core/_SmpSpinlockKernel.c b/SylixOS/kernel/core/_SmpSpinlockKernel.c
index 342db1b..69764b8 100644
--- a/SylixOS/kernel/core/_SmpSpinlockKernel.c
+++ b/SylixOS/kernel/core/_SmpSpinlockKernel.c
@@ -147,6 +147,66 @@ VOID _SmpKernelUnlockSched (PLW_CLASS_TCB ptcbOwner)
iRet = __ARCH_SPIN_UNLOCK(&LW_KERN_SL, pcpuCur);
_BugFormat((iRet != LW_SPIN_OK), LW_TRUE, "unlock error %p!\r\n", &LW_KERN_SL);
}
+/*********************************************************************************************************
+ 内核时间自旋锁
+*********************************************************************************************************/
+#define LW_KERN_TIME_SL (_K_slKernTime.SLCA_sl)
+/*********************************************************************************************************
+** 函数名称: _SmpKernTimeLockIgnIrq
+** 功能描述: 内核时间自旋锁加锁操作, 忽略中断锁定 (必须在中断关闭的状态下被调用)
+** 输 入 : NONE
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID _SmpKernTimeLockIgnIrq (VOID)
+{
+ __ARCH_SPIN_LOCK_RAW(&LW_KERN_TIME_SL);
+ KN_SMP_MB();
+}
+/*********************************************************************************************************
+** 函数名称: _SmpKernTimeUnlockIgnIrq
+** 功能描述: 内核时间自旋锁解锁操作, 忽略中断锁定 (必须在中断关闭的状态下被调用)
+** 输 入 : NONE
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID _SmpKernTimeUnlockIgnIrq (VOID)
+{
+ KN_SMP_MB();
+ __ARCH_SPIN_UNLOCK_RAW(&LW_KERN_TIME_SL);
+}
+/*********************************************************************************************************
+** 函数名称: _SmpKernTimeLockQuick
+** 功能描述: 内核时间自旋锁加锁操作, 连同锁定中断
+** 输 入 : piregInterLevel 中断锁定信息
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID _SmpKernTimeLockQuick (INTREG *piregInterLevel)
+{
+ *piregInterLevel = KN_INT_DISABLE();
+
+ __ARCH_SPIN_LOCK_RAW(&LW_KERN_TIME_SL);
+ KN_SMP_MB();
+}
+/*********************************************************************************************************
+** 函数名称: _SmpKernTimeUnlockQuick
+** 功能描述: 内核时间自旋锁解锁操作, 连同解锁中断, 不进行尝试调度
+** 输 入 : iregInterLevel 中断锁定信息
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID _SmpKernTimeUnlockQuick (INTREG iregInterLevel)
+{
+ KN_SMP_MB();
+ __ARCH_SPIN_UNLOCK_RAW(&LW_KERN_TIME_SL);
+
+ KN_INT_ENABLE(iregInterLevel);
+}
#endif /* LW_CFG_SMP_EN */
/*********************************************************************************************************
diff --git a/SylixOS/kernel/core/_UpSpinlockKernel.c b/SylixOS/kernel/core/_UpSpinlockKernel.c
index d007659..e59d48d 100644
--- a/SylixOS/kernel/core/_UpSpinlockKernel.c
+++ b/SylixOS/kernel/core/_UpSpinlockKernel.c
@@ -108,6 +108,52 @@ VOID _UpKernelUnlockSched (PLW_CLASS_TCB ptcbOwner)
__THREAD_LOCK_DEC(ptcbOwner); /* 解锁任务在当前 CPU */
}
}
+/*********************************************************************************************************
+** 函数名称: _UpKernTimeLockIgnIrq
+** 功能描述: 内核时间自旋锁加锁操作, 忽略中断锁定 (必须在中断关闭的状态下被调用)
+** 输 入 : NONE
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID _UpKernTimeLockIgnIrq (VOID)
+{
+}
+/*********************************************************************************************************
+** 函数名称: _UpKernTimeUnlockIgnIrq
+** 功能描述: 内核时间自旋锁解锁操作, 忽略中断锁定 (必须在中断关闭的状态下被调用)
+** 输 入 : NONE
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID _UpKernTimeUnlockIgnIrq (VOID)
+{
+}
+/*********************************************************************************************************
+** 函数名称: _UpKernTimeLockQuick
+** 功能描述: 内核时间自旋锁加锁操作, 连同锁定中断
+** 输 入 : piregInterLevel 中断锁定信息
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID _UpKernTimeLockQuick (INTREG *piregInterLevel)
+{
+ *piregInterLevel = KN_INT_DISABLE();
+}
+/*********************************************************************************************************
+** 函数名称: _UpKernTimeUnlockQuick
+** 功能描述: 内核时间自旋锁解锁操作, 连同解锁中断, 不进行尝试调度
+** 输 入 : iregInterLevel 中断锁定信息
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID _UpKernTimeUnlockQuick (INTREG iregInterLevel)
+{
+ KN_INT_ENABLE(iregInterLevel);
+}
#endif /* LW_CFG_SMP_EN */
/*********************************************************************************************************
diff --git a/SylixOS/kernel/core/_WakeupLine.c b/SylixOS/kernel/core/_WakeupLine.c
index 0c058fc..06c2b27 100644
--- a/SylixOS/kernel/core/_WakeupLine.c
+++ b/SylixOS/kernel/core/_WakeupLine.c
@@ -44,7 +44,7 @@ VOID _WakeupAdd (PLW_CLASS_WAKEUP pwu, PLW_CLASS_WAKEUP_NODE pwun, BOOL bPro
BOOL bSaveTime = LW_FALSE;
if (bProcTime && plineTemp && pwu->WU_pfuncWakeup) { /* 非周期任务时间预处理 */
- __KERNEL_TIME_GET_NO_SPINLOCK(i64CurTime, INT64);
+ __KERNEL_TIME_GET(i64CurTime, INT64);
ulCounter = (ULONG)(i64CurTime - pwu->WU_i64LastTime);
pwu->WU_i64LastTime = i64CurTime;
@@ -86,7 +86,7 @@ VOID _WakeupAdd (PLW_CLASS_WAKEUP pwu, PLW_CLASS_WAKEUP_NODE pwun, BOOL bPro
if (bProcTime && pwu->WU_pfuncWakeup) {
if (bSaveTime) {
- __KERNEL_TIME_GET_NO_SPINLOCK(pwu->WU_i64LastTime, INT64);
+ __KERNEL_TIME_GET(pwu->WU_i64LastTime, INT64);
}
pwu->WU_pfuncWakeup(pwu->WU_pvWakeupArg); /* 唤醒 */
}
@@ -119,7 +119,7 @@ VOID _WakeupDel (PLW_CLASS_WAKEUP pwu, PLW_CLASS_WAKEUP_NODE pwun, BOOL bPro
}
if (bProcTime && !_list_line_get_prev(&pwun->WUN_lineManage) && pwu->WU_pfuncWakeup) {
- __KERNEL_TIME_GET_NO_SPINLOCK(i64CurTime, INT64); /* 非周期任务时间预处理 */
+ __KERNEL_TIME_GET(i64CurTime, INT64); /* 非周期任务时间预处理 */
ulCounter = (ULONG)(i64CurTime - pwu->WU_i64LastTime);
pwu->WU_i64LastTime = i64CurTime;
@@ -165,7 +165,7 @@ VOID _WakeupStatus (PLW_CLASS_WAKEUP pwu, PLW_CLASS_WAKEUP_NODE pwun, ULONG
if (plineTemp) {
if (pwu->WU_i64LastTime) { /* 包含时间预处理 */
- __KERNEL_TIME_GET_NO_SPINLOCK(i64CurTime, INT64);
+ __KERNEL_TIME_GET(i64CurTime, INT64);
ulDelta = (ULONG)(i64CurTime - pwu->WU_i64LastTime);
ulCounter = (ulCounter > ulDelta) ? (ulCounter - ulDelta) : 0ul;
}
diff --git a/SylixOS/kernel/include/k_globalvar.h b/SylixOS/kernel/include/k_globalvar.h
index 9b05fc3..4718985 100644
--- a/SylixOS/kernel/include/k_globalvar.h
+++ b/SylixOS/kernel/include/k_globalvar.h
@@ -262,6 +262,14 @@ __KERNEL_EXT LW_CLASS_PHYCPU _K_phycpuTable[LW_CFG_MAX_PROCESSORS];
__KERNEL_EXT LW_CLASS_KERNLOCK _K_klKernel; /* 内核锁 */
#endif /* __KERNEL_MAIN_FILE */
/*********************************************************************************************************
+ 内核时间锁
+*********************************************************************************************************/
+#ifdef __KERNEL_MAIN_FILE
+LW_SPINLOCK_CA_DEFINE_CACHE_ALIGN (_K_slKernTime);
+#else
+__KERNEL_EXT LW_SPINLOCK_CA_DECLARE (_K_slKernTime);
+#endif
+/*********************************************************************************************************
原子操作锁
*********************************************************************************************************/
#ifdef __KERNEL_MAIN_FILE
diff --git a/SylixOS/kernel/include/k_internal.h b/SylixOS/kernel/include/k_internal.h
index 83f46c4..b0d3371 100644
--- a/SylixOS/kernel/include/k_internal.h
+++ b/SylixOS/kernel/include/k_internal.h
@@ -266,6 +266,9 @@ BOOL __kernelSchedIntCheck(PLW_CLASS_CPU pcpuCur);
#define __KERNEL_TIME_GET(time, type) \
__KERNEL_TIME_GET_NO_SPINLOCK(time, type)
+#define __KERNEL_TIME_GET_IGNIRQ(time, type) \
+ __KERNEL_TIME_GET_NO_SPINLOCK(time, type)
+
#else /* LW_CFG_CPU_ATOMIC64_EN */
#define __KERNEL_TIME_GET_NO_SPINLOCK(time, type) \
{ \
@@ -274,9 +277,16 @@ BOOL __kernelSchedIntCheck(PLW_CLASS_CPU pcpuCur);
#define __KERNEL_TIME_GET(time, type) \
{ \
INTREG iregInterLevel; \
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel); \
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel); \
+ time = (type)_K_atomic64KernelTime.counter; \
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel); \
+ }
+
+#define __KERNEL_TIME_GET_IGNIRQ(time, type) \
+ { \
+ LW_SPIN_KERN_TIME_LOCK_IGNIRQ(); \
time = (type)_K_atomic64KernelTime.counter; \
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel); \
+ LW_SPIN_KERN_TIME_UNLOCK_IGNIRQ(); \
}
#endif /* !LW_CFG_CPU_ATOMIC64_EN */
diff --git a/SylixOS/kernel/include/k_kernel.h b/SylixOS/kernel/include/k_kernel.h
index 6dbbb2f..a0af215 100644
--- a/SylixOS/kernel/include/k_kernel.h
+++ b/SylixOS/kernel/include/k_kernel.h
@@ -51,7 +51,7 @@
#define __SYLIXOS_MAJOR_VER 1
#define __SYLIXOS_MINOR_VER 12
-#define __SYLIXOS_PATCH_VER 6
+#define __SYLIXOS_PATCH_VER 7
#define __SYLIXOS_PATCH_PAD 0
/*********************************************************************************************************
@@ -100,7 +100,7 @@ __attribute__((weak)) char __sylixos_version[] = __SYLIXOS_VERSTR;
*********************************************************************************************************/
#include "k_logo.h"
-
+
/*********************************************************************************************************
系统配置与裁减头文件
*********************************************************************************************************/
diff --git a/SylixOS/kernel/include/k_spinlock.h b/SylixOS/kernel/include/k_spinlock.h
index 6acfc54..a06cb51 100644
--- a/SylixOS/kernel/include/k_spinlock.h
+++ b/SylixOS/kernel/include/k_spinlock.h
@@ -154,6 +154,22 @@ VOID _SmpKernelUnlockSched(struct __lw_tcb *ptcbOwner);
#define LW_SPIN_KERN_UNLOCK_SCHED(ptcb) _SmpKernelUnlockSched(ptcb)
+/*********************************************************************************************************
+ SMP 内核时间锁操作.
+*********************************************************************************************************/
+
+VOID _SmpKernTimeLockIgnIrq(VOID);
+VOID _SmpKernTimeUnlockIgnIrq(VOID);
+
+VOID _SmpKernTimeLockQuick(INTREG *piregInterLevel);
+VOID _SmpKernTimeUnlockQuick(INTREG iregInterLevel);
+
+#define LW_SPIN_KERN_TIME_LOCK_IGNIRQ() _SmpKernTimeLockIgnIrq()
+#define LW_SPIN_KERN_TIME_UNLOCK_IGNIRQ() _SmpKernTimeUnlockIgnIrq()
+
+#define LW_SPIN_KERN_TIME_LOCK_QUICK(pireg) _SmpKernTimeLockQuick(pireg)
+#define LW_SPIN_KERN_TIME_UNLOCK_QUICK(ireg) _SmpKernTimeUnlockQuick(ireg)
+
#else
/*********************************************************************************************************
单处理器伪自旋锁
@@ -230,6 +246,22 @@ VOID _UpKernelUnlockSched(struct __lw_tcb *ptcbOwner);
#define LW_SPIN_KERN_UNLOCK_SCHED(ptcb) _UpKernelUnlockSched(ptcb)
+/*********************************************************************************************************
+ 单处理器内核时间锁操作
+*********************************************************************************************************/
+
+VOID _UpKernTimeLockIgnIrq(VOID);
+VOID _UpKernTimeUnlockIgnIrq(VOID);
+
+VOID _UpKernTimeLockQuick(INTREG *piregInterLevel);
+VOID _UpKernTimeUnlockQuick(INTREG iregInterLevel);
+
+#define LW_SPIN_KERN_TIME_LOCK_IGNIRQ() _UpKernTimeLockIgnIrq()
+#define LW_SPIN_KERN_TIME_UNLOCK_IGNIRQ() _UpKernTimeUnlockIgnIrq()
+
+#define LW_SPIN_KERN_TIME_LOCK_QUICK(pireg) _UpKernTimeLockQuick(pireg)
+#define LW_SPIN_KERN_TIME_UNLOCK_QUICK(ireg) _UpKernTimeUnlockQuick(ireg)
+
#endif /* LW_CFG_SMP_EN */
#endif /* __K_SPINLOCK_H */
/*********************************************************************************************************
diff --git a/SylixOS/kernel/interface/EventSetGet.c b/SylixOS/kernel/interface/EventSetGet.c
index 4a050e3..0d3f865 100644
--- a/SylixOS/kernel/interface/EventSetGet.c
+++ b/SylixOS/kernel/interface/EventSetGet.c
@@ -152,7 +152,7 @@ __wait_again:
if (ulTimeout == LW_OPTION_NOT_WAIT) { /* 不等待 */
__EVENTSET_NOT_READY();
} /* 阻塞线程 */
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
_EventSetBlock(pes, &esnNode, ulEvent, ucWaitType, ulWaitTime);
}
break;
@@ -174,7 +174,7 @@ __wait_again:
if (ulTimeout == LW_OPTION_NOT_WAIT) { /* 不等待 */
__EVENTSET_NOT_READY();
} /* 阻塞线程 */
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
_EventSetBlock(pes, &esnNode, ulEvent, ucWaitType, ulWaitTime);
}
break;
@@ -196,7 +196,7 @@ __wait_again:
if (ulTimeout == LW_OPTION_NOT_WAIT) { /* 不等待 */
__EVENTSET_NOT_READY();
} /* 阻塞线程 */
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
_EventSetBlock(pes, &esnNode, ulEvent, ucWaitType, ulWaitTime);
}
break;
@@ -218,7 +218,7 @@ __wait_again:
if (ulTimeout == LW_OPTION_NOT_WAIT) { /* 不等待 */
__EVENTSET_NOT_READY();
} /* 阻塞线程 */
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
_EventSetBlock(pes, &esnNode, ulEvent, ucWaitType, ulWaitTime);
}
break;
diff --git a/SylixOS/kernel/interface/KernelTicks.c b/SylixOS/kernel/interface/KernelTicks.c
index cb35351..ff9cec1 100644
--- a/SylixOS/kernel/interface/KernelTicks.c
+++ b/SylixOS/kernel/interface/KernelTicks.c
@@ -167,15 +167,19 @@ VOID API_KernelTicksContext (VOID)
PLW_CLASS_CPU pcpu;
PLW_CLASS_TCB ptcb;
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel); /* 锁定内核并关闭中断 */
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel); /* 锁定内核时间并关闭中断 */
#if LW_CFG_RTC_EN > 0
__kernelTODUpdate(); /* 更新 TOD 时间 */
#endif /* LW_CFG_RTC_EN > 0 */
__kernelTickUpdate(); /* 更新 TICK 时间 */
- KN_INT_ENABLE(iregInterLevel); /* 允许其他中断进入 */
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel); /* 解锁内核时间并打开中断 */
+
+ LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel); /* 锁定内核并关闭中断 */
+ KN_INT_ENABLE(iregInterLevel); /* 允许其他中断进入 */
+
#if LW_CFG_SMP_EN > 0
LW_CPU_FOREACH (i) { /* 遍历所有的核 */
#else
diff --git a/SylixOS/kernel/interface/MsgQueueReceive.c b/SylixOS/kernel/interface/MsgQueueReceive.c
index 632a110..950b390 100644
--- a/SylixOS/kernel/interface/MsgQueueReceive.c
+++ b/SylixOS/kernel/interface/MsgQueueReceive.c
@@ -179,7 +179,7 @@ __wait_again:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) {
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
@@ -369,7 +369,7 @@ __wait_again:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) {
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
diff --git a/SylixOS/kernel/interface/MsgQueueSend.c b/SylixOS/kernel/interface/MsgQueueSend.c
index 2db6df2..bbb55d9 100644
--- a/SylixOS/kernel/interface/MsgQueueSend.c
+++ b/SylixOS/kernel/interface/MsgQueueSend.c
@@ -184,7 +184,7 @@ __re_send:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) {
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
diff --git a/SylixOS/kernel/interface/MsgQueueSendEx.c b/SylixOS/kernel/interface/MsgQueueSendEx.c
index 83a96b7..e56821e 100644
--- a/SylixOS/kernel/interface/MsgQueueSendEx.c
+++ b/SylixOS/kernel/interface/MsgQueueSendEx.c
@@ -190,7 +190,7 @@ __re_send:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) {
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
diff --git a/SylixOS/kernel/interface/SemaphoreBPend.c b/SylixOS/kernel/interface/SemaphoreBPend.c
index bf22efa..d2325c5 100644
--- a/SylixOS/kernel/interface/SemaphoreBPend.c
+++ b/SylixOS/kernel/interface/SemaphoreBPend.c
@@ -136,7 +136,7 @@ __wait_again:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) { /* 按优先级等待 */
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
diff --git a/SylixOS/kernel/interface/SemaphoreBPendEx.c b/SylixOS/kernel/interface/SemaphoreBPendEx.c
index 9aa8769..abcf5c9 100644
--- a/SylixOS/kernel/interface/SemaphoreBPendEx.c
+++ b/SylixOS/kernel/interface/SemaphoreBPendEx.c
@@ -144,7 +144,7 @@ __wait_again:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) { /* 按优先级等待 */
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
diff --git a/SylixOS/kernel/interface/SemaphoreCPend.c b/SylixOS/kernel/interface/SemaphoreCPend.c
index 6d0fd9a..e1e341b 100644
--- a/SylixOS/kernel/interface/SemaphoreCPend.c
+++ b/SylixOS/kernel/interface/SemaphoreCPend.c
@@ -136,7 +136,7 @@ __wait_again:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) { /* 按优先级等待 */
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
diff --git a/SylixOS/kernel/interface/SemaphoreMPend.c b/SylixOS/kernel/interface/SemaphoreMPend.c
index 84d9826..66fc8e3 100644
--- a/SylixOS/kernel/interface/SemaphoreMPend.c
+++ b/SylixOS/kernel/interface/SemaphoreMPend.c
@@ -173,7 +173,7 @@ __wait_again:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) { /* 按优先级等待 */
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
diff --git a/SylixOS/kernel/interface/SemaphorePostPend.c b/SylixOS/kernel/interface/SemaphorePostPend.c
index baf108d..95de4bc 100644
--- a/SylixOS/kernel/interface/SemaphorePostPend.c
+++ b/SylixOS/kernel/interface/SemaphorePostPend.c
@@ -144,7 +144,7 @@ __wait_again:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) { /* 按优先级等待 */
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
@@ -316,7 +316,7 @@ __wait_again:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) { /* 按优先级等待 */
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
diff --git a/SylixOS/kernel/interface/SemaphoreRWPend.c b/SylixOS/kernel/interface/SemaphoreRWPend.c
index d619ba9..7af70e1 100644
--- a/SylixOS/kernel/interface/SemaphoreRWPend.c
+++ b/SylixOS/kernel/interface/SemaphoreRWPend.c
@@ -125,7 +125,7 @@ __wait_again:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) { /* 按优先级等待 */
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
@@ -273,7 +273,7 @@ __wait_again:
} else {
ptcbCur->TCB_ulDelay = ulTimeout; /* 设置超时时间 */
}
- __KERNEL_TIME_GET_NO_SPINLOCK(ulTimeSave, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulTimeSave, ULONG); /* 记录系统时间 */
if (pevent->EVENT_ulOption & LW_OPTION_WAIT_PRIORITY) { /* 按优先级等待 */
_EVENT_INDEX_Q_PRIORITY(ptcbCur->TCB_ucPriority, ucPriorityIndex);
diff --git a/SylixOS/kernel/interface/TimeSleep.c b/SylixOS/kernel/interface/TimeSleep.c
index 65844a2..8bb85fb 100644
--- a/SylixOS/kernel/interface/TimeSleep.c
+++ b/SylixOS/kernel/interface/TimeSleep.c
@@ -93,7 +93,7 @@ __wait_again:
ptcbCur->TCB_ulDelay = ulTick;
__ADD_TO_WAKEUP_LINE(ptcbCur); /* 加入等待扫描链 */
- __KERNEL_TIME_GET_NO_SPINLOCK(ulKernelTime, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulKernelTime, ULONG); /* 记录系统时间 */
if (__KERNEL_EXIT_IRQ(iregInterLevel)) { /* 被信号激活 */
ulTick = _sigTimeoutRecalc(ulKernelTime, ulTick); /* 重新计算等待时间 */
@@ -144,7 +144,7 @@ __wait_again:
ptcbCur->TCB_ulDelay = ulTick;
__ADD_TO_WAKEUP_LINE(ptcbCur); /* 加入等待扫描链 */
- __KERNEL_TIME_GET_NO_SPINLOCK(ulKernelTime, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulKernelTime, ULONG); /* 记录系统时间 */
if (__KERNEL_EXIT_IRQ(iregInterLevel)) { /* 被信号激活 */
if (bSigRet) {
@@ -284,12 +284,12 @@ static VOID __timeGetHighResolution (struct timespec *ptv)
{
INTREG iregInterLevel;
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel);
*ptv = _K_tvTODMono;
#if LW_CFG_TIME_HIGH_RESOLUTION_EN > 0
bspTickHighResolution(ptv); /* 高精度时间分辨率计算 */
#endif /* LW_CFG_TIME_HIGH_RESOLUT... */
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel);
}
/*********************************************************************************************************
** 函数名称: __timePassSpec
@@ -393,7 +393,7 @@ __wait_again:
ptcbCur->TCB_ulDelay = ulTick;
__ADD_TO_WAKEUP_LINE(ptcbCur); /* 加入等待扫描链 */
- __KERNEL_TIME_GET_NO_SPINLOCK(ulKernelTime, ULONG); /* 记录系统时间 */
+ __KERNEL_TIME_GET_IGNIRQ(ulKernelTime, ULONG); /* 记录系统时间 */
iSchedRet = __KERNEL_EXIT_IRQ(iregInterLevel); /* 调度器解锁 */
if (iSchedRet == LW_SIGNAL_EINTR) {
diff --git a/SylixOS/kernel/interface/TimeTod.c b/SylixOS/kernel/interface/TimeTod.c
index ecdd9c9..dabfab5 100644
--- a/SylixOS/kernel/interface/TimeTod.c
+++ b/SylixOS/kernel/interface/TimeTod.c
@@ -40,14 +40,14 @@ VOID API_TimeTodAdj (INT32 *piDelta, INT32 *piOldDelta)
{
INTREG iregInterLevel;
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel);
if (piOldDelta) {
*piOldDelta = _K_iTODDelta;
}
if (piDelta) {
_K_iTODDelta = *piDelta;
}
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel);
}
/*********************************************************************************************************
** 函数名称: API_TimeTodAdjEx
@@ -76,7 +76,7 @@ INT API_TimeTodAdjEx (INT32 *piDelta, INT32 *piDeltaNs, INT32 *piOldDelta, IN
return (PX_ERROR);
}
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel);
if (piOldDelta) {
*piOldDelta = _K_iTODDelta;
}
@@ -89,7 +89,7 @@ INT API_TimeTodAdjEx (INT32 *piDelta, INT32 *piDeltaNs, INT32 *piOldDelta, IN
if (piDeltaNs) {
_K_iTODDeltaNs = *piDeltaNs;
}
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel);
return (ERROR_NONE);
}
diff --git a/SylixOS/lib/libc/time/lib_clock.c b/SylixOS/lib/libc/time/lib_clock.c
index 317684c..48201ab 100644
--- a/SylixOS/lib/libc/time/lib_clock.c
+++ b/SylixOS/lib/libc/time/lib_clock.c
@@ -142,17 +142,17 @@ INT lib_clock_gettime (clockid_t clockid, struct timespec *tv)
switch (clockid) {
case CLOCK_REALTIME:
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel);
*tv = _K_tvTODCurrent;
LW_TIME_HIGH_RESOLUTION(tv);
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel);
break;
case CLOCK_MONOTONIC:
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel);
*tv = _K_tvTODMono;
LW_TIME_HIGH_RESOLUTION(tv);
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel);
break;
case CLOCK_PROCESS_CPUTIME_ID:
@@ -211,11 +211,11 @@ INT lib_clock_settime (clockid_t clockid, const struct timespec *tv)
return (PX_ERROR);
}
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel);
_K_tvTODCurrent = *tv;
_K_iTODDelta = 0; /* 清除之前的微调时间 */
_K_iTODDeltaNs = 0;
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel);
return (ERROR_NONE);
}
@@ -249,14 +249,14 @@ INT lib_clock_nanosleep (clockid_t clockid, int iFlags,
if (iFlags == TIMER_ABSTIME) { /* 绝对时间 */
struct timespec tvNow;
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel);
if (clockid == CLOCK_REALTIME) {
tvNow = _K_tvTODCurrent;
} else {
tvNow = _K_tvTODMono;
}
LW_TIME_HIGH_RESOLUTION(&tvNow);
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel);
if (__timespecLeftTime(rqtp, &tvNow)) {
return (ERROR_NONE); /* 不需要延迟 */
diff --git a/SylixOS/lib/libc/time/lib_time.c b/SylixOS/lib/libc/time/lib_time.c
index 7538e49..5ee11ca 100644
--- a/SylixOS/lib/libc/time/lib_time.c
+++ b/SylixOS/lib/libc/time/lib_time.c
@@ -37,9 +37,9 @@ time_t lib_time (time_t *time)
INTREG iregInterLevel;
time_t timetmp;
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel);
timetmp = _K_tvTODCurrent.tv_sec;
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel);
if (time) {
*time = timetmp;
@@ -60,9 +60,9 @@ time_t lib_timelocal (time_t *time)
INTREG iregInterLevel;
time_t timetmp;
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel);
timetmp = UTC2LOCAL(_K_tvTODCurrent.tv_sec);
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel);
if (time) {
*time = timetmp;
@@ -83,9 +83,9 @@ time_t time (time_t *time)
INTREG iregInterLevel;
time_t timetmp;
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
+ LW_SPIN_KERN_TIME_LOCK_QUICK(&iregInterLevel);
timetmp = _K_tvTODCurrent.tv_sec;
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
+ LW_SPIN_KERN_TIME_UNLOCK_QUICK(iregInterLevel);
if (time) {
*time = timetmp;
diff --git a/SylixOS/net/lwip/lwip_ifctl.c b/SylixOS/net/lwip/lwip_ifctl.c
index fba2134..9b8a768 100644
--- a/SylixOS/net/lwip/lwip_ifctl.c
+++ b/SylixOS/net/lwip/lwip_ifctl.c
@@ -915,6 +915,44 @@ INT __ifIoctlWireless (INT iCmd, PVOID pvArg)
#endif /* LW_CFG_NET_WIRELESS_EN > 0 */
/*********************************************************************************************************
+** 函数名称: __ifIoctlPrivate
+** 功能描述: 网络接口私有 ioctl 操作
+** 输 入 : iCmd 命令
+** pvArg 参数
+** 输 出 : 处理结果
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+INT __ifIoctlPrivate (INT iCmd, PVOID pvArg)
+{
+ INT iRet = PX_ERROR;
+ struct ifreq *pifreq;
+ struct netif *pnetif;
+
+ if (pvArg == LW_NULL) {
+ _ErrorHandle(EINVAL);
+ return (iRet);
+ }
+
+ pifreq = (struct ifreq *)pvArg;
+
+ LWIP_IF_LIST_LOCK(LW_FALSE); /* 进入临界区 */
+ pnetif = netif_find(pifreq->ifr_name);
+ if (pnetif == LW_NULL) {
+ _ErrorHandle(EADDRNOTAVAIL);
+
+ } else {
+ if (pnetif->ioctl) {
+ iRet = pnetif->ioctl(pnetif, iCmd, pvArg);
+ } else {
+ _ErrorHandle(ENOSYS);
+ }
+ }
+ LWIP_IF_LIST_UNLOCK(); /* 退出临界区 */
+
+ return (iRet);
+}
+/*********************************************************************************************************
** 函数名称: __ifIoctlPacket
** 功能描述: PACKET 网络接口 ioctl 操作
** 输 入 : iCmd 命令
diff --git a/SylixOS/net/lwip/lwip_ifctl.h b/SylixOS/net/lwip/lwip_ifctl.h
index c0c4b00..b3bd0b6 100644
--- a/SylixOS/net/lwip/lwip_ifctl.h
+++ b/SylixOS/net/lwip/lwip_ifctl.h
@@ -34,6 +34,7 @@ extern INT __ifIoctlPacket(INT iCmd, PVOID pvArg);
extern INT __ifIoctlWireless(INT iCmd, PVOID pvArg);
#endif /* LW_CFG_NET_WIRELESS_EN > 0 */
+extern INT __ifIoctlPrivate(INT iCmd, PVOID pvArg);
extern INT __ifIoctlLp(INT iCmd, PVOID pvArg);
#endif /* LW_CFG_NET_EN */
diff --git a/SylixOS/net/lwip/lwip_socket.c b/SylixOS/net/lwip/lwip_socket.c
index 32bb4fe..928b1b9 100644
--- a/SylixOS/net/lwip/lwip_socket.c
+++ b/SylixOS/net/lwip/lwip_socket.c
@@ -755,7 +755,11 @@ static INT __socketIoctl (SOCKET_T *psock, INT iCmd, PVOID pvArg)
iRet = __ifIoctlWireless(iCmd, pvArg);
} else
#endif /* LW_CFG_NET_WIRELESS_EN > 0 */
- {
+ if ((iCmd >= SIOCDEVPRIVATE) &&
+ (iCmd <= SIOCDEVPRIVATE + 0xf)) { /* 网卡私有命令 */
+ iRet = __ifIoctlPrivate(iCmd, pvArg);
+
+ } else {
iRet = lwip_ioctl(psock->SOCK_iLwipFd, (long)iCmd, pvArg);
}
break;
diff --git a/SylixOS/system/device/rand/randDevLib.c b/SylixOS/system/device/rand/randDevLib.c
index 6ea4302..92e6d85 100644
--- a/SylixOS/system/device/rand/randDevLib.c
+++ b/SylixOS/system/device/rand/randDevLib.c
@@ -59,7 +59,7 @@ static VOID __randInterHook (ULONG ulVector, ULONG ulNesting)
if (LW_IVEC_GET_FLAG(ulVector) & LW_IRQ_FLAG_SAMPLE_RAND) { /* 需要更新随机数种子 */
LW_SPIN_LOCK_QUICK(&_G_slRandLock, &iregInterLevel);
- _G_tvLastInt = _K_tvTODCurrent;
+ _G_tvLastInt = _K_tvTODCurrent; /* 仅仅是种子, 不需要加时间锁 */
_G_i64IntCounter++;
LW_SPIN_UNLOCK_QUICK(&_G_slRandLock, iregInterLevel);
}
diff --git a/SylixOS/system/signal/signalLib.c b/SylixOS/system/signal/signalLib.c
index d0e955f..96c56f0 100644
--- a/SylixOS/system/signal/signalLib.c
+++ b/SylixOS/system/signal/signalLib.c
@@ -573,7 +573,8 @@ static VOID __sigCtlCreate (PLW_CLASS_TCB ptcb,
pstkSignalShell = archTaskCtxCreate(&ptcb->TCB_archRegCtx,
(PTHREAD_START_ROUTINE)__sigShell,
(PVOID)psigctlmsg,
- ptcb, (PLW_STACK)pucStkNow, 0); /* 建立信号外壳环境 */
+ ptcb, (PLW_STACK)pucStkNow,
+ ptcb->TCB_ulOption); /* 建立信号外壳环境 */
archTaskCtxSetFp(pstkSignalShell,
&ptcb->TCB_archRegCtx,
@@ -1103,7 +1104,6 @@ BOOL _sigPendRun (PLW_CLASS_TCB ptcb)
*********************************************************************************************************/
ULONG _sigTimeoutRecalc (ULONG ulOrgKernelTime, ULONG ulOrgTimeout)
{
- INTREG iregInterLevel;
REGISTER ULONG ulTimeRun;
ULONG ulKernelTime;
@@ -1111,12 +1111,10 @@ ULONG _sigTimeoutRecalc (ULONG ulOrgKernelTime, ULONG ulOrgTimeout)
return (ulOrgTimeout);
}
- LW_SPIN_KERN_LOCK_QUICK(&iregInterLevel);
- __KERNEL_TIME_GET_NO_SPINLOCK(ulKernelTime, ULONG);
+ __KERNEL_TIME_GET(ulKernelTime, ULONG); /* 获得当前系统时间 */
ulTimeRun = (ulKernelTime >= ulOrgKernelTime) ?
(ulKernelTime - ulOrgKernelTime) :
(ulKernelTime + (__ARCH_ULONG_MAX - ulOrgKernelTime) + 1);
- LW_SPIN_KERN_UNLOCK_QUICK(iregInterLevel);
if (ulTimeRun >= ulOrgTimeout) { /* 已经产生了超时 */
return (0);