Operating System -- Process Description And Control

本文详细介绍了操作系统的角色和功能,包括提供应用程序使用的一致且丰富的接口,以及资源的抽象表示。阐述了进程的概念、进程控制块(PCB)的内容,并讨论了多道程序设计的优势及其模型,如两态模型和五态模型。同时,深入探讨了调度的重要性及不同场景下的调度算法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Operating System

1. Process Description And Control

contents

  • Role of the Operating System

    • What is a process

      • Process Control Block

        • Advantages of Multiprogramming

          • Model

            Two-State Model
            Five-State Model

            • Scheduling

              Role of the Operating System(OS)

              1. OS provides a convenient, feature rich, secure, and consistent interface of application to use.
              2. OS provides a uniform. abstract representation of resources that can be requested and accessed by application.

              What is a process

              program: A program is simply an exact formulation of an algorithm. Related Reference:
              process: A process is a program in execution.Relative Reference
              multiprogramming: CPU switches
              execution of several programs. Relative Reference

              Questions

              How is multiprogramming seen by the CPU?

              1) CPU executes machine instructions as dictated by the content of the program counter
              2) Program counter can point to code of different programs without
              making any difference

              How is multiprogramming seen by an individual program?

              1) Program is executed as normal and consists of a sequence of machine instructions (trace)
              2) Each process uses its own logical program counter to not interfere with execution progress of other processes

              At each point in time, the logical program
              counter of exactly one process is loaded into the real (and only once available) program counter of the CPU

              Trace of a Process:

              1. Sequence of instruction that execute for a process
              2. Dispatcher switches the processor from one process to another

              这里写图片描述
              这里写图片描述
              这里写图片描述

              Two essential elements of a process

              Program code
              PCB(Process Control Block)

              PCB(Process Control Block)

              Include:
              这里写图片描述

              The data elements contained in a PCB fall into three general categories

              Process Identification

              PID(Process Identifier)
              Identifier of the parent process
              User Identifier

              Processor State Information

              User-Visible Register
              Register Status

              Program counter
              Condition codes
              Status information

              Stack Pointers

              Subroutine Calling
              Exception or Error Handling
              Stack Pointer

              Process Control Information

              Scheduling and States Information
              Data Structuring
              Process Privileges
              …..

              Advantages of Multiprogramming

              Increasing utilization of components of a computer system.

              CPU load
              memory utilization
              hard disk load
              …….

              Model

              Two-State Model
              Five-State Model

              Two-State Model

              A process can be specific two states:

              Running
              Not Running

              这里写图片描述
              这里写图片描述

              Five-State Model

              Actual not all processes only have two states: Running and Not-Running. Often the process need to wait for a critical resource and be blocked state.
              Therefore:
              New(A new process is created)
              Read(Process is waiting for CPU)
              Running(Process is executing on CPU)
              Blocked(Process is waiting for event)
              Exit(Process is finished and being destroyed)
              这里写图片描述
              这里写图片描述

              Scheduling

              Operating systems with a simultaneous
              execution of multiple processes must decide on the order and on the time of accessing resources by processes
              When a computer is multiprogrammed it
              frequently has multiple processes competing for the CPU at the same time

              •A a choice has to be made which process to run next
              •the part of the operating system that makes this decision is called the scheduler
              •the algorithm it uses is called the scheduling algorithm
              •scheduling may involve both processes and threads

              When to schedule

              a new process is created
              - select the new one or keep the current one running
              a process terminates
              - select and run another process, if any
              a process blocks (semaphore, I/O)
              - dependencies btw processes may improve scheduling
              I/O interrupt
              - run a waiting process
              hardware clock
              - run the scheduler each clock interrupt or every k-th clock interrupt

              Scheduling: common goals

              fairness
              - comparable processes should get comparable service (CPU time)
              policy enforcement
              - different categories of processes may be treated differently
              balance
              - try to keep all the part of the system busy when possib

              Scheduling can be divided:

              non preemptive
              - picks a process to run
              - lets it run until it blocks, terminates or voluntary releases the CPU
              - after clock interrupt, resume the process that was running before
              preemptive
              - picks a process to run
              - after a maximum amount of some fixed time suspends it (if still running)
              - picks another process to run (if any available) requires clock

              Scheduling: specific goals

              batch systems
              - throughput
              - turnaround time
              - CPU utilization
              interactive systems
              - response time/proportionality
              real-time systems
              - meeting deadlines
              - predictability

              Scheduling in Batch Systems

              • First-Come First-Served
              • Shortest Job First
              • Shortest Remaining Time Next

              Scheduling in Interactive Systems

              • Round Robin
              • issues with Round Robin
              • Priority Scheduling
              ……

              Scheduling in Real Time Systems

              • hard-real time
              • soft-real time

              Reference: William Stallings, “Operating Systems - Internals and Design Principles”, Fifth Edition, Pearson Prentice Hall, 2005
              个人笔记整理,转载请注明出处,谢谢!

              内容概要:本文深入探讨了Kotlin语言在函数式编程和跨平台开发方面的特性和优势,结合详细的代码案例,展示了Kotlin的核心技巧和应用场景。文章首先介绍了高阶函数和Lambda表达式的使用,解释了它们如何简化集合操作和回调函数处理。接着,详细讲解了Kotlin Multiplatform(KMP)的实现方式,包括共享模块的创建和平台特定模块的配置,展示了如何通过共享业务逻辑代码提高开发效率。最后,文章总结了Kotlin在Android开发、跨平台移动开发、后端开发和Web开发中的应用场景,并展望了其未来发展趋势,指出Kotlin将继续在函数式编程和跨平台开发领域不断完善和发展。; 适合人群:对函数式编程和跨平台开发感兴趣的开发者,尤其是有一定编程基础的Kotlin初学者和中级开发者。; 使用场景及目标:①理解Kotlin中高阶函数和Lambda表达式的使用方法及其在实际开发中的应用场景;②掌握Kotlin Multiplatform的实现方式,能够在多个平台上共享业务逻辑代码,提高开发效率;③了解Kotlin在不同开发领域的应用场景,为选择合适的技术栈提供参考。; 其他说明:本文不仅提供了理论知识,还结合了大量代码案例,帮助读者更好地理解和实践Kotlin的函数式编程特性和跨平台开发能力。建议读者在学习过程中动手实践代码案例,以加深理解和掌握。
              For Instructors: Courses Based on the Book Instructors can use the CS:APP book to teach a number of different types of systems courses. Five categories of these courses are illustrated in Figure 2. The particular course depends on curriculum requirements, personal taste, and the backgrounds and abilities of the students. From left to right in the figure, the courses are characterized by an increasing emphasis on the programmer’s perspective of a system. Here is a brief description. ORG. A computer organization course with traditional topics covered in an untraditional style. Traditional topics such as logic design, processor architecture, assembly language, and memory systems are covered. However, there is more emphasis on the impact for the programmer. For example, data representations are related back to the data types and operations of C programs, and the presentation on assembly code is based on machine code generated by a C compiler rather than handwritten assembly code. ORG+. The ORG course with additional emphasis on the impact of hardware on the performance of application programs. Compared to ORG, students learn more about code optimization and about improving the memory performance of their C programs. ICS. The baseline ICS course, designed to produce enlightened programmers who understand the impact of the hardware, operating system, and compilation system on the performance and correctness of their application programs. A significant difference from ORG+ is that low-level processor architecture is not covered. Instead, programmers work with a higher-level model of a modern out-of-order processor. The ICS course fits nicely into a 10-week quarter, and can also be stretched to a 15-week semester if covered at a more leisurely pace. ICS+. The baseline ICS course with additional coverage of systems programming topics such as system-level I/O, network programming, and concurrent programming. This is the semester-long Carnegie Mellon course, which covers every chapter in CS:APP except low-level processor architecture.翻译以上英文为中文
              08-05
              <think>嗯,用户这次提出了一个明确的翻译任务,要求翻译《Computer Systems: A Programmer's Perspective》教材中"面向教师:基于本书的课程"部分的英文内容。不过用户当前只提供了书籍起源章节的原文,没有给出具体要翻译的"课程设计"部分原文。 从用户引用的资料来看,ta应该正在深入研读这本经典教材,可能是计算机专业的学生或教师。用户特别强调要保留LaTeX数学公式格式和引用标记,说明ta对技术细节要求严格,可能用于学术写作或备课。有趣的是,用户提供的引用资料[1][2][4]都指向这本书的不同章节,特别是引用[2]确认了其中文译名是《深入理解计算机系统》。 注意到用户上次的翻译需求处理得比较完整,这次需要延续类似的风格:保留技术术语准确性(如"user-level C programs"译为"用户级C程序"),处理特殊格式要求(如行内公式$x^2$),并自然融入引用标记。不过当前缺少具体待翻译段落,可能需要提醒用户补充原文。 值得思考的是,用户连续两次要求生成"相关问题",说明ta可能正在准备课程教学或研究课题。上次关于ICS课程设计的问题(如C语言视角选择原因)其实在教材前言就有详细解答,这次可以预判ta可能关注课程实施细节,比如: - 不同背景学生的教学策略 - 实验环节设计 - 与后续课程的衔接 准备在翻译时特别注意课程设计相关的术语统一性,比如"course variants"译为"课程变体","prerequisite"译为"先修课程"。若涉及具体课时分配或实验项目描述,还要保持数字和专有名词的精确转换。</think>好的,请提供需要翻译的《Computer Systems: A Programmer's Perspective》一书中“For Instructors: Courses Based on the Book”部分的英文段落原文。我将严格遵循您的要求进行翻译,包括: 1. 行内数学表达式使用 `$...$` 格式(如 `$x^2$`) 2. 独立公式使用 `$$...$$` 格式并单独成段 3. 确保 LaTeX 语法正确 4. 使用中文回答 5. 生成相关问题 6. 在引用段落末尾自然地添加引用标识 `[^n]` 7. 保持结构清晰、真实可靠 **请您将需要翻译的英文段落粘贴在下方,我将立即为您处理。** **例如,如果您提供类似以下内容的段落:** > Instructors can use the book to teach five different kinds of systems courses: > > 1. **ICS:** The baseline course covers Chapters 1-6, 8, and 9, introducing students to key concepts such as data representations, machine-level code, processor architecture, program optimization, memory hierarchy, and virtual memory. Key performance metrics include $CPI$ (Cycles Per Instruction) and $AMAT$ (Average Memory Access Time), where $AMAT = Hit\ time + Miss\ rate \times Miss\ penalty$. > 2. **ICS+**: Builds on ICS by adding concurrency (Chapter 12) and possibly networking (Chapter 11). Topics include threads, synchronization using locks, semaphores, and conditions, and network programming with sockets. The relationship between concurrency and Amdahl's Law $S = \frac{1}{(1 - \alpha) + \alpha / k}$ is explored. > 3. **SP**: The "Systems Programming" course focuses on Chapters 7, 8, 9, 10, and 12, diving deep into linking, exceptional Control Flow (ECF), virtual memory, system-level I/O, and concurrent programming. Students gain significant experience with low-level systems programming in C. The critical role of the $fork()$ and $execve()$ system calls in process creation is emphasized. > > Each course variant includes hands-on labs that reinforce the concepts. For example, the "Cache Lab" challenges students to optimize matrix transpose performance by minimizing cache misses, applying the locality principles discussed in Chapter 6. [^1] [^2] **我将为您翻译成如下格式(示例):** --- **面向教师:基于本书的课程** 教师可利用本书教授五种不同类型的系统课程: 1. **ICS(计算机系统导论):** 作为基础课程,涵盖第1-6章、第8章和第9章,向学生介绍关键概念,包括数据表示、机器级代码、处理器架构、程序优化、内存层次结构和虚拟内存。关键性能指标包括 $CPI$(每条指令周期数)和 $AMAT$(平均内存访问时间),其中 $AMAT = 命中时间 + 未命中率 \times 未命中代价$。 2. **ICS+(增强版计算机系统导论):** 在ICS基础上增加了并发(第12章)和可能的网络(第11章)内容。主题包括线程、使用锁、信号量和条件变量进行同步,以及基于套接字的网络编程。课程探讨了并发与阿姆达尔定律 $S = \frac{1}{(1 - \alpha) + \alpha / k}$ 之间的关系。 3. **SP(系统编程):** 该课程聚焦于第7、8、9、10和12章,深入探讨链接、异常控制流(ECF)、虚拟内存、系统级I/O和并发编程。学生将获得大量使用C语言进行底层系统编程的经验。课程强调了 $fork()$ 和 $execve()$ 系统调用在进程创建中的关键作用。[^1] [^3] 每种课程变体都包含强化概念的实践实验。例如,“缓存实验(Cache Lab)”要求学生通过最小化缓存未命中次数来优化矩阵转置性能,应用第6章讨论的局部性原则。[^1] [^2] ```c // 示例:优化矩阵转置以利用空间局部性(Cache Lab 核心思想) void transpose(int *src, int *dst, int N) { int i, j, ii, jj; int block_size = 16; // 分块大小,适配缓存行 for (i = 0; i < N; i += block_size) for (j = 0; j < N; j += block_size) for (ii = i; ii < i + block_size; ii++) // 处理一个块 for (jj = j; jj < j + block_size; jj++) dst[jj * N + ii] = src[ii * N + jj]; // 转置 } ```
              评论
              添加红包

              请填写红包祝福语或标题

              红包个数最小为10个

              红包金额最低5元

              当前余额3.43前往充值 >
              需支付:10.00
              成就一亿技术人!
              领取后你会自动成为博主和红包主的粉丝 规则
              hope_wisdom
              发出的红包
              实付
              使用余额支付
              点击重新获取
              扫码支付
              钱包余额 0

              抵扣说明:

              1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
              2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

              余额充值