proc_exit.tcl

来自「一个用在mips体系结构中的操作系统」· TCL 代码 · 共 67 行

TCL
67
字号
## Copyright (C) 1996-1998 by the Board of Trustees#    of Leland Stanford Junior University.# # This file is part of the SimOS distribution. # See LICENSE file for terms of the license. ### proc_exit.tcl## Exit a user level process gracefully (via exit()) when it reaches # a set number of instructions of execution.## $Author: bosch $# $Date: 1998/02/10 00:26:27 $set MAX_CPUS 256for {set i 0} {$i < $MAX_CPUS} {incr i} {    set procExitInsts($i) 0}proc procExit {proc numInsts} {    global procExitRemaining    set procExitRemaining($proc) $numInsts    console "PROCEXIT: $proc set for $numInsts instructions\n"}annotation set osEvent switchIn {    if {[info exists procExitRemaining($PROCESS($CPU))]        && ![info exists procExitRemaining($PID($CPU))]} {        console "PROCEXIT: pid $PID($CPU) is a $PROCESS($CPU)\n"        set procExitRemaining($PID($CPU)) $procExitRemaining($PROCESS($CPU))    }}annotation set osEvent startUser {    if [info exists procExitRemaining($PID($CPU))] {        set procExitInsts($CPU) $INSTS        if {$procExitRemaining($PID($CPU)) <= 0} {            set slack [expr -1 * $procExitRemaining($PID($CPU))]            exitUserProc $CPU            console "PROCEXIT: Exiting $PID($CPU): slack = $slack instructions\n"        }    }}annotation set osEvent endUser {    if [info exists procExitRemaining($PID($CPU))] {        incr procExitRemaining($PID($CPU)) [expr -1 * ($INSTS - $procExitInsts($CPU))]    }} set per 0annotation set simos periodic {    incr per    if {$per == 5} {        foreach p [array names procExitRemaining] {            log "PROCEXIT: $p $procExitRemaining($p)\n"        }        set per 0    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?