rCore-Tutorial-v3/ch5/os/task/index.html

39 lines
13 KiB
HTML
Raw Normal View History

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Task management implementation"><meta name="keywords" content="rust, rustlang, rust-lang, task"><title>os::task - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../os/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../os/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Module task</a></h2><div class="sidebar-elems"><section><div class="block"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#constants">Constants</a></li><li><a href="#functions">Functions</a></li></ul></div></section></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../os/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">os</a>::<wbr><a class="mod" href="#">task</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/os/task/mod.rs.html#1-121">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Task management implementation</p>
<p>Everything about task management, like starting and switching tasks is
implemented here.</p>
<p>A single global instance of <a href="manager/struct.TaskManager.html" title="TaskManager"><code>TaskManager</code></a> called <code>TASK_MANAGER</code> controls
all the tasks in the whole operating system.</p>
<p>A single global instance of <a href="processor/struct.Processor.html" title="Processor"><code>Processor</code></a> called <code>PROCESSOR</code> monitors running
task(s) for each core.</p>
<p>A single global instance of <a href="pid/struct.PidAllocator.html" title="PidAllocator"><code>PidAllocator</code></a> called <code>PID_ALLOCATOR</code> allocates
pid for user apps.</p>
<p>Be careful when you see <code>__switch</code> ASM function in <code>switch.S</code>. Control flow around this function
might not be what you expect.</p>
</div></details><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="context/index.html" title="os::task::context mod">context</a><span title="Restricted Visibility">&nbsp;🔒</span> </div><div class="item-right docblock-short"><p>Implementation of <a href="context/struct.TaskContext.html" title="TaskContext"><code>TaskContext</code></a></p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="manager/index.html" title="os::task::manager mod">manager</a><span title="Restricted Visibility">&nbsp;🔒</span> </div><div class="item-right docblock-short"><p>Implementation of <a href="manager/struct.TaskManager.html" title="TaskManager"><code>TaskManager</code></a></p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="pid/index.html" title="os::task::pid mod">pid</a><span title="Restricted Visibility">&nbsp;🔒</span> </div><div class="item-right docblock-short"><p>Implementation of <a href="pid/struct.PidAllocator.html" title="PidAllocator"><code>PidAllocator</code></a></p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="processor/index.html" title="os::task::processor mod">processor</a><span title="Restricted Visibility">&nbsp;🔒</span> </div><div class="item-right docblock-short"><p>Implementation of <a href="processor/struct.Processor.html" title="Processor"><code>Processor</code></a> and Intersection of control flow</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="switch/index.html" title="os::task::switch mod">switch</a><span title="Restricted Visibility">&nbsp;🔒</span> </div><div class="item-right docblock-short"><p>Wrap <code>switch.S</code> as a function</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="task/index.html" title="os::task::task mod">task</a><span title="Restricted Visibility">&nbsp;🔒</span> </div><div class="item-right docblock-short"><p>Implementation of <a href="task/struct.TaskControlBlock.html" title="TaskControlBlock"><code>TaskControlBlock</code></a></p>
</div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.INITPROC.html" title="os::task::INITPROC struct">INITPROC</a></div><div class="item-right docblock-short"><p>Globle process that init user shell</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.KernelStack.html" title="os::task::KernelStack struct">KernelStack</a></div><div class="item-right docblock-short"><p>Kernelstack for app</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.PidAllocator.html" title="os::task::PidAllocator struct">PidAllocator</a></div><div class="item-right docblock-short"><p>Pid Allocator struct</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.PidHandle.html" title="os::task::PidHandle struct">PidHandle</a></div><div class="item-right docblock-short"><p>Bind pid lifetime to <code>PidHandle</code></p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Processor.html" title="os::task::Processor struct">Processor</a></div><div class="item-right docblock-short"><p>Processor management structure</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.TaskContext.html" title="os::task::TaskContext struct">TaskContext</a></div><div class="item-right docblock-short"><p>task context structure containing some registers</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.TaskManager.html" title="os::task::TaskManager struct">TaskManager</a></div><div class="item-right docblock-short"><p>A array of <code>TaskControlBlock</code> that is thread-safe</p>
</div></div></div><h2 id="constants" class="small-section-header"><a href="#constants">Constants</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.IDLE_PID.html" title="os::task::IDLE_PID constant">IDLE_PID</a></div><div class="item-right docblock-short"><p>pid of usertests app in make run TEST=1</p>
</div></div></div><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.add_initproc.html" title="os::task::add_initproc fn">add_initproc</a></div><div class="item-right docblock-short"><p>Add init process to the manager</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.add_task.html" title="os::task::add_task fn">add_task</a></div><div class="item-right docblock-short"><p>Interface offered to add task</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.current_task.html" title="os::task::current_task fn">current_task</a></div><div class="item-right docblock-short"><p>Get running task</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.current_trap_cx.html" title="os::task::current_trap_cx fn">current_trap_cx</a></div><div class="item-right docblock-short"><p>Get the mutable reference to trap context of current task</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.current_user_token.html" title="os::task::current_user_token fn">current_user_token</a></div><div class="item-right docblock-short"><p>Get token of the address space of current task</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.exit_current_and_run_next.html" title="os::task::exit_current_and_run_next fn">exit_current_and_run_next</a></div><div class="item-right docblock-short"><p>Exit the current Running task and run the next task in task list.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.fetch_task.html" title="os::task::fetch_task fn">fetch_task</a></div><div class="item-right docblock-short"><p>Interface offered to pop the first task</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.pid_alloc.html" title="os::task::pid_alloc fn">pid_alloc</a></div><div class="item-right docblock-short"><p>Allocate a pid from PID_ALLOCATOR</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.run_tasks.html" title="os::task::run_tasks fn">run_tasks</a></div><div class="item-right docblock-short"><p>The main part of process execution and scheduling
Loop <code>fetch_task</code> to get the process that needs to run, and switch the process through <code>__switch</code></p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.schedule.html" title="os::task::schedule fn">schedule</a></div><div class="item-right docblock-short"><p>Return to idle control flow for new scheduling</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.suspend_current_and_run_next.html" title="os::task::suspend_current_and_run_next fn">suspend_current_and_run_next</a></div><div class="item-right docblock-short"><p>Suspend the current Running task and run the next task in task list.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.take_current_task.html" title="os::task::take_current_task fn">take_current_task</a></div><div class="item-right docblock-short"><p>Take the current task,leaving a None in its place</p>
</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="os" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (f6f9d5e73 2022-08-04)" ></div></body></html>