操作系统(Operating System)4

本文详细阐述了进程和线程的概念及其区别,包括它们的基本属性、执行状态、资源分配方式等,并介绍了用户级线程和内核级线程的特点及优缺点。此外,还讨论了并行处理的应用场景。

线程与进程(Process & Threads)

-Process  is an infrastructure in which execution takes place  (address space + resources)

-Thread  is a program component executing within a process context – each thread has its own execution stack

Each thread has:
    an execution state运行状态
    an execution stack
    saved thread context 
    some static storage for local variables
    access to the memory and resources of its process
简单来说就是,首先要有个对应的状态,然后要有执行栈,然后可以在非运行状态保存当前内容以便再次运行,然后可以存贮一些信息,可以被处理器运行
线程的好处:
    创建新的线程(Thread)比进程(Process)用时少
    终止Thread比Process更快
    在两个Thread之间交替更块
    thread之间交流更高效

 User-Level Threads(ULT)
     所有的线程都由应用处理好了

     劣势:
         当一个ULT锁定了系统调用时,所有的在相同进程中的线程都将被锁定
         不能利用多线程的优势

Kernel-Level Threads(KLT)
    例如:Windows & Linux
    所有工作由kernel完成(项目中没有线程管理)
    优势:
    劣势:
Combined Approaches
    例如: SUN Solaris

**Parallel Execution 平行处理**

Applications That Benefit
    Multithreaded native applications
        characterized by having a small number of highly threaded processes

    Multiprocess applications

        characterized by the presence of many single-threaded processes
    Java applications

    Multiinstance applications

        multiple instances of the application in parallel


Hyper-threading
是inter的噫哥主要的处理同时多线程(simultaneous multithreading SMT)一项技术,可以提高x86微处理器的性能。

Hyper-threading = logical core

对于每一个物理存在的处理器,操作系统的地址时两个虚拟的或是逻辑核心,在可能的情况下分享工作量  

For each processor core that is physically present, the operating system addresses two virtual or logical cores, and shares the workload between them when possible. The main function of hyper-threading is to increase the number of independent instructions in the pipeline; it takes advantage of superscalar architecture, in which multiple instructions operate on separate data in parallel. With HTT, one physical core appears as two processors to the operating system, which can use each core to schedule two processes at once. In addition, two or more processes can use the same resources: if resources for one process are not available, then another process can continue if its resources are available.

### 麒麟操作系统安装时出现 'Operating System not found' 的解决方案 当在 VM 虚拟机环境中尝试安装麒麟操作系统并遇到 `Operating System not found` 错误时,通常是因为虚拟机未正确加载 ISO 映像文件或者配置不完整所致。以下是针对该问题的具体分析和解决办法: #### 1. **确认虚拟机设置** 确保虚拟机已正确配置启动设备顺序。通过编辑虚拟机设置,调整 BIOS 启动优先级,使光驱(CD/DVD 或 ISO 文件)成为首选启动项[^1]。 ```plaintext 具体操作步骤: - 打开虚拟机软件(如 VMware Workstation/Player 或 VirtualBox)。 - 右键点击目标虚拟机 -> 编辑虚拟机设置。 - 进入“选项”->“高级”,检查引导顺序是否设置了 CD/DVD 为第一启动项。 ``` #### 2. **验证 ISO 镜像文件的有效性** 错误可能源于使用的 ISO 镜像文件损坏或版本不适配。建议从官方渠道重新下载最新的麒麟操作系统镜像文件,并校验其 MD5 值以确保完整性[^2]。 ```bash # 使用以下命令计算本地 ISO 文件的 MD5 校验值并与官网提供的一致性对比 md5sum kylin-os.iso ``` #### 3. **指定正确的 ISO 映像路径** 如果 ISO 文件路径未被正确定位,则可能导致系统无法识别启动介质。需手动指定 ISO 文件的位置,并确保虚拟机能够访问它[^4]。 ```plaintext 具体操作步骤: - 返回到虚拟机设置窗口中的“硬件”部分。 - 添加一个新的 CD/DVD 设备。 - 将模式更改为“使用 ISO 映像文件”。 - 浏览至存储有合法麒麟 OS 镜像文件的目录完成关联绑定。 ``` #### 4. **检查虚拟硬盘状态** 有时即使提供了有效的启动媒介仍会出现此提示,可能是由于虚拟硬盘尚未初始化或格式化不当引起。创建新的虚拟硬盘或将现有磁盘重置后再试一次可能会解决问题[^3]。 --- ### 示例代码片段:自动挂载ISO脚本 (适用于某些环境) 对于批量部署场景下频繁更换不同OS镜像的情况,可编写简单脚本来简化流程: ```python import os def mount_iso(iso_path, vm_name): command = f"vmrun -T ws connectCdrom {vm_name} {iso_path}" result = os.system(command) if result == 0: print(f"{vm_name}'s cdrom successfully mounted with {iso_path}.") else: print("Failed to mount the iso file.") if __name__ == "__main__": iso_file_location = "/path/to/kylin-os.iso" virtual_machine_identifier = "KylinVM" mount_iso(iso_file_location, virtual_machine_identifier) ``` --- #### 总结 上述方法涵盖了大部分因配置失误引发的操作系统找不到类别的常见原因处理方式。实际应用过程中可根据具体情况灵活选用其中一种或多组合策略来排除故障。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值