📄 mk_schedcreator.cxx
字号:
/* * Copyright (C) 1998, 1999, 2001, Jonathan S. Shapiro. * * This file is part of the EROS Operating System. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include <kerninc/kernel.hxx>#include <kerninc/Key.hxx>#include <eros/Invoke.h>#include <eros/Reserve.h>#include <eros/SchedCreKey.h>#include <kerninc/Invocation.hxx>#include <kerninc/CpuReserve.hxx>#include <kerninc/Machine.hxx>#include <kerninc/Thread.hxx>#include <eros/StdKeyType.h>voidSchedCreatorKey(Invocation& inv){#ifndef OPTION_PURE_EXIT_STRINGS if (inv.entry.code == OC_SchedCre_Get) inv.invokee->SetupExitString(inv, sizeof(CpuReserveInfo));#endif#ifndef OPTION_PURE_ENTRY_STRINGS if (inv.entry.code == OC_SchedCre_Set) Thread::CurContext()->SetupEntryString(inv);#endif COMMIT_POINT(); switch(inv.entry.code) { case OC_SchedCre_GetLimit: { inv.exit.w1 = MAX_CPU_RESERVE; break; } case OC_SchedCre_Get: { uint32_t ndx; ndx = inv.entry.w1; if (ndx < STD_CPU_RESERVE || ndx >= MAX_CPU_RESERVE) { inv.exit.code = RC_RequestError; return; } CpuReserveInfo rsrvinfo; CpuReserve& rsrv = CpuReserve::CpuReserveTable[ndx]; rsrvinfo.index = ndx; rsrvinfo.period = Machine::TicksToMilliseconds(rsrv.period); rsrvinfo.duration = Machine::TicksToMilliseconds(rsrv.duration); rsrvinfo.quanta = Machine::TicksToMilliseconds(rsrv.quanta); rsrvinfo.start = Machine::TicksToMilliseconds(rsrv.start); rsrvinfo.rsrvPrio = rsrv.rsrvPrio; rsrvinfo.normPrio = rsrv.normPrio; inv.CopyOut(sizeof(rsrvinfo), &rsrvinfo); break; } case OC_SchedCre_Set: { if (inv.entry.len < sizeof(CpuReserveInfo)) { inv.exit.code = RC_RequestError; return; } CpuReserveInfo ri; inv.CopyIn(sizeof(CpuReserveInfo), &ri); if (ri.index < STD_CPU_RESERVE || ri.index >= MAX_CPU_RESERVE) { inv.exit.code = RC_RequestError; return; } CpuReserve& rsrv = CpuReserve::CpuReserveTable[ri.index]; rsrv.reserveTimer.Disarm(); rsrv.period = Machine::MillisecondsToTicks(ri.period); rsrv.duration = Machine::MillisecondsToTicks(ri.duration); rsrv.quanta = Machine::MillisecondsToTicks(ri.quanta); rsrv.start = Machine::MillisecondsToTicks(ri.start); rsrv.rsrvPrio = ri.rsrvPrio; rsrv.normPrio = ri.normPrio; rsrv.residQuanta = rsrv.quanta; rsrv.residDuration = rsrv.duration; if (rsrv.residDuration) rsrv.residDuration -= rsrv.quanta; rsrv.Reset(); if (inv.exit.pKey[0]) { inv.exit.pKey[0]->InitType(KT_Sched); inv.exit.pKey[0]->keyData = ri.index; } /* Rest of void key is right for this call. */ break; } case OC_KeyType: { inv.exit.code = RC_OK; inv.exit.w1 = inv.keyType; break; } default: inv.exit.code = RC_UnknownRequest; break; } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -