首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >`/usr/lib/pm-utils/睡眠.d/94cpufreq‘试图做什么?

`/usr/lib/pm-utils/睡眠.d/94cpufreq‘试图做什么?
EN

Unix & Linux用户
提问于 2018-04-02 23:03:57
回答 1查看 250关注 0票数 2

在我的Ubuntu16.04上,我正在尝试理解一个系统默认文件/usr/lib/pm-utils/sleep.d/94cpufreq (关于它的内容,请参阅本文的结尾)。

考虑到"${PM_FUNCTIONS}"是由.提供的,它是脚本吗?

当我在bash中echo "${PM_FUNCTIONS}"时,它什么也不输出。PM_FUNCTIONS是在另一个调用脚本的脚本中定义的吗?

savestatestate_existsrestorestate函数是否在"${PM_FUNCTIONS}"中定义?

TEMPORARY_CPUFREQ_GOVERNOR"是在"${PM_FUNCTIONS}"中定义的变量吗?

脚本试图在suspend|hibernatethaw|resume上做什么?

谢谢。

代码语言:javascript
复制
#!/bin/sh                                                                                                                                                                          
# Ensure cpu governor is set to something sane.                                                                                                                                    
# TODO: Which of the cpu governors is still insane?  File bugs against                                                                                                             
#       those that are.                                                                                                                                                            

. "${PM_FUNCTIONS}"

[ -d /sys/devices/system/cpu/ ] || exit $NA

hibernate_cpufreq()
{
  ( cd /sys/devices/system/cpu/
  for x in cpu[0-9]*; do
    # if cpufreq is a symlink, it is handled by another cpu. Skip.                                                                                                                 
    [ -L "$x/cpufreq" ] && continue
    gov="$x/cpufreq/scaling_governor"
    # if we do not have a scaling_governor file, skip.                                                                                                                             
    [ -f "$gov" ] || continue
    # if our temporary governor is not available, skip.                                                                                                                            
    grep -q "$TEMPORARY_CPUFREQ_GOVERNOR" \
            "$x/cpufreq/scaling_available_governors" || continue
    savestate "${x}_governor" < "$gov"
    echo "$TEMPORARY_CPUFREQ_GOVERNOR" > "$gov"
  done )
}

thaw_cpufreq()
{
  ( cd /sys/devices/system/cpu/
  for x in cpu[0-9]*/cpufreq/scaling_governor ; do
    [ -f "$x" ] || continue
    state_exists "${x%%/*}_governor" || continue
    restorestate "${x%%/*}_governor" > "$x"
  done )
}

case "$1" in
  suspend|hibernate)
    hibernate_cpufreq
    ;;
  resume|thaw)
    thaw_cpufreq
    ;;
  *) exit $NA
    ;;
esac
EN

回答 1

Unix & Linux用户

发布于 2018-04-02 23:24:07

state_exists等函数是在/usr/lib/pm-utils/函数中定义的,PM_FUNCTIONS是指脚本/usr/lib/pm-utils/pm-函数。是的,TEMPORARY_CPUFREQ_GOVERNOR是在PM_FUNCTIONS中定义的。

票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/435150

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档