嵌入式LINUX-复习整理_2019

上传人:努力****83 文档编号:177480527 上传时间:2022-12-25 格式:DOC 页数:26 大小:1.06MB
返回 下载 相关 举报
嵌入式LINUX-复习整理_2019_第1页
第1页 / 共26页
嵌入式LINUX-复习整理_2019_第2页
第2页 / 共26页
嵌入式LINUX-复习整理_2019_第3页
第3页 / 共26页
点击查看更多>>
资源描述
chp1 Overview of embedded systems1. Definition of embedded system:The Special purpose computer system which are centered in application, based on computer technology, and their software and hardware can be cut out , they can meet the strict requirements of the application system for function, reliability, cost, volume, and power.2. Characteristics of embedded system:1) For specific applications, there are generally real-time requirements.2) Its a constantly innovating knowledge integration system which integrates advanced computer technology, semiconductor technology, electronic technology and communication network technology.3) Embedded system is organically integrated with the specific application object, so its upgrade and replacement is also synchronized with the specific products.4) The software and hardware design of embedded system focuses on high efficiency. For meeting the application requirements to the maximum extent, reducing the cost is a major problem that must be considered.5) Embedded system software is generally solidified in memory chips, rather than stored in disks and other carriers.3. The composition of embedded system:Embedded system is usually composed of embedded processor, embedded peripherals, embedded operating system and embedded application software.4. What are the types of embedded processors?EMPU (embedded microprocessor unit)EMCU (embedded microcontroller unit)EDSP (embedded digital signal processor)ESOC (embedded system on chip)5. What are the functions of embedded peripherals?Auxiliary functions(辅助功能) such as storage, communication, protection, debugging, display, etc.6. What kinds of embedded peripherals can be divided into?Memory: RAM, SRAM, DRAM, ROM, EPROM, EEPROM, FLASH, etc.I/O interface: RS-232, IRDA(红外线数据输入输出), I2C(现场总线), SPI(串行外设接口) , USB, Ethernet, EPP, etc. Input and Output Equipments: Keyboard, LCD, LED, CRT, Touch screen, etc.7. List some kinds of embedded operating system:Windows CE, Embedded Linux, Palm OS, pSOS, Delta OS,Android, MontaVistaReal-time: VxWorks, C/OS , C/OS, QNX,8.Difference between RTOS(Real-time Operation System) and general OS:1) Real time: Fast response speed: us Execution time is determined and predictable.2) Small size code: 10100KB3) Application program development is difficult4) Dedicated development tools: Simulator, Compiler, Debugger9. Characteristics of RTOS :1) Support synchronization synchronization between processes coordinate shared data(协调共享数据)2) Priority mechanism(优先级机制) for interrupt and scheduling tasksSupport preemptive scheduling(抢占式调度)3) Determined task switching and interrupt delay time Important! 4) Support for asynchronous event(异步事件) response Response to external events within specified time10. Application of embedded system:1) Information appliance network (信息家电网络)2) Military defense3) Traffic electronic equipments4) Medical instruments5) Industrial controlChapter 2. Basic Concepts1. main steps to creating a target Linux system1). Determine system components.2). Configure and build the kernel.3). Build the root filesystem.4). Set up boot software and configuration.2. Three different host/target architectures : (1) Linked setup (连接式) (2) Removable storage setup(可抽换式存储设备) (3) Standalone setup(独立式)CHP5 The Linux Kernel1. Kernel mode and user mode, kernel space and user space2. Difference between monolithic kernel(单一内核) and micro kernel(微内核) Linux- monolithic kernel3. Composition of the Linux Kernel: five subsystems:1) Process scheduling 2) Inter process communication(IPC)3) Memory managementMemory page (4KB) 4) Virtual file system(VFS) 4 object models Super block object Index node object File object Directory object5) Network interfaceIn addition, also includes device drivers and some general tasks and mechanisms. 1.进程调度(SCHED):控制进程对CPU的访问。当需要选择下一个进程运行时,由调度程序选择最值得运行的进程。可运行进程实际上是仅等待CPU资源的进程,如果某个进程在等待其它资源,则该进程是不可运行进程。Linux使用了比较简单的基于优先级的进程调度算法选择新的进程。2.内存管理(MMU)允许多个进程安全的共享主内存区域。Linux 的内存管理支持虚拟内存,即在计算机中运行的程序,其代码,数据,堆栈的总量可以超过实际内存的大小,操作系统只是把当前使用的程序块保留在内存中,其余的程序块则保留在磁盘中。必要时,操作系统负责在磁盘和内存间交换程序块。内存管理从逻辑上分为硬件无关部分和硬件有关部分。硬件无关部分提供了进程的映射和逻辑内存的对换;硬件相关的部分为内存管理硬件提供了虚拟接口。3.虚拟文件系统(Virtual File System,VFS)隐藏了各种硬件的具体细节,为所有的设备提供了统一的接口,VFS提供了多达数十种不同的文件系统。虚拟文件系统可以分为逻辑文件系统和设备驱动程序。逻辑文件系统指Linux所支持的文件系统,如ext2,fat等,设备驱动程序指为每一种硬件控制器所编写的设备驱动程序模块。4.网络接口(NET)提供了对各种网络标准的存取和各种网络硬件的支持。网络接口可分为网络协议和网络驱动程序。网络协议部分负责实现每一种可能的网络传输协议。网络设备驱动程序负责与硬件设备通讯,每一种可能的硬件设备都有相应的设备驱动程序。5.进程间通讯(IPC) 支持进程间各种通信机制。4. The Linux system includes the following types of processes: Interactive process(交互进程): the process is controlled and run by shell. It can run in the foreground or in the background. Batch process(批处理进程): This process does not belong to a terminal and is submitted to a queue for sequential execution. Daemon (守护进程): This process is called back in the background only when needed.It usually starts when Linux starts.5. Description of processA process is a general term for a program in execution and related resources.(进程是处于执行期的程序以及相关资源的总称) The process is dynamic, and the process is changing all the time when the processor executes the machine code. Processes include not only program instructions and data, but also program counters and all CPU registers, as well as the process stack that stores temporary data. The ongoing process includes all the current activities of the processor. 6. Processes go through the following states in sequence: Create, ready or active, produce (create and activate), run, block, rerun, complete, and ready (when there is an infinite loop in the process).Finally, release or delete (in a long process, blocking and rerun can happen many times). 7. The process management program implements the following functions:1) Enables processes to execute sequentially, or block when resources are needed, and to continue running when resources are available.2) Logical links to resource managers are implemented for resource management (including process scheduling on the CPU).3) Restrict certain resources to be shared only among certain processes.4) Allocate resources according to the resource allocation mechanism of the system.5) Manage the process and resources in the system.8. The state of the process:TASK_RUNNING(运行状态)TASK_INTERRUPTIBLE (可中断睡眠状态) TASK_UNINTERRUPTIBLE (不可中断睡眠状态) TASK_STOPPED (暂停状态) Task_ZOMBIE(僵死状态) TASK_INTERRUPTIBLE(可中断睡眠状态) when a process is in an interruptible wait state, the system will not schedule the execution of the process. When the system produces an interrupt or releases the resource that the process is waiting for, or the process receives a signal, it can wake up the process to switch to the ready state (running state). TASK_UNINTERRUPTIBLE (不可中断睡眠状态) Its similar to TASK_INTERRUPTIBLE state. But a process in this state can be switched to a runnable ready state only when it is waken up by the wake_up () function. TASK_STOPPED (暂停状态) When the process receives the signal SIGSTOP, SIGTSTP, SIGTTIN or SIGTTOU, it will enter TASK_STOPPED state. SIGCONT signals can be sent to the process to make it run. TASK_ZOMBIE(僵死状态) When a process has stopped running but its parent has not asked for its state, is said to be in TASK_ZOMBIE state.Processes running in kernel state cannot be preempted by other processes, and one process cannot change the state of another process. To avoid kernel data errors during process switching, the kernel prohibits all interrupts when executing critical section code(临界区代码). 9. TCB(Task Control Block)contains task context(任务上下文)records handles(句柄), priorities, and subsidiary data(附属数据) for some processes.The process state is stored in the state field of TCB. 10. Task vector table(任务向量表):The kernel program manages the process through the task vector table(任务向量表), and each process occupies one item in the vector table. In Linux, the task vector table item is a task_struct task structure pointer. When a new process is created, the process management module allocates a new task_struct from system memory and adds it to the task vector table.11. The context of the process(进程上下文)When a process is executed, the values in all registers of the CPU, the state of the process, and the contents of the stack are called the context of the process(进程上下文)In Linux, the context of the current process is stored in the task data structure of the process。 When the kernel needs to switch to another process, it needs to save the context of the current process12. Creation of processThe Linux system uses inheritance(继承) to create process. The creation of a new process is achieved by cloning the old process, or cloning the current process. When the system starts-up, it runs in the kernel mode. At this time, there is only one process: init process. All processes in the system are descendants(后代) of the init process . 13. Scheduling of processThe Linux process is preemptive (抢占式的). The preempted (被抢占的) process is still in the TASK_RUNNING state, but it is temporarily not run by CPU. The preemption of a process occurs when the process is in the execution phase of user mode . It can not be preempted when the process is executed in the kernel mode. In Linux, priority queuing scheduling strategy is adopted.Multitasks share CPU resources by Time Slicing(分时)Time slice(时间片)- A short time in which each process is allowedto run , usually 200 milliseconds14. The scheduling strategy of the process (调度策略)Linux has two types of processes: general and real-time.There are two strategies for real-time processes: 1) Round Robin(循环) each real-time process runs in turn(依次)2) First-in First-outeach runnable process runs in its order in the scheduling queue, which does not change15. Every time it runs, the scheduler completes the following tasks :1) kernel work Runs bottom half handler and processes the systems scheduling task queue.2) Current poccess Processes the current process before selecting another process. If the scheduling policy of the current process is Round Robin, put it at the end of the running queue. If the task is interruptible and it received a signal the last time it was scheduled, change its state to RUNNING. If the current process is timeout, changes its state to RUNNING. If the state of the current process is RUNNING, this state is maintained. Delete the processes from the running queue which are not in RUNNING or INTERRUPTIBLE state. 3) Process Selection Look at the processes in the running queue to find the most worthwhile process.4) Swap (交换) Processes If the process that is most worth running is not the current process, the current process must be suspended to run the new process. 16. The scheduling process :1) scan the task queue. 2) By comparing the value of the decrement counter for each TASK_RUNNING task, determine which process currently runs for the least time(which task has the largest counter value ), so the process is selected and switched to the process.3) If all the time slices of processes in TASK_RUNNING state are used up, the system recalculates the time slice counter of each task for all processes in the system, including the sleeping process, based on the priority of each process.The formula is: counter = counter/2 + priority4) The schedule () function then rescans the TASK_RUNNING state of the task queue again, repeating the process until a process is selected. 5) Finally, call switch_to () to perform the actual process switching operation.课件例题17. Termination of processWhen a process finishes running or stops running halfway, the kernel needs to release the system resources that the process occupies. This includes files opened by the process running, memory for application, etc.When a user program invokes the exit () system call, it executes the kernel function do_exit ().18. Memory management:Linux adopts Request Paging Virtual Memory Management method(请求式分页虚拟存储管理方法).Linux provides virtul memory space of 4GB for every process.The virtual memory of each process is independent and insulate with each other, so running a process will not influnce another process.Virtual memory management mechanism allows write- protection of memory areas(内存区写保护), which prevents code and data from being overwritten by error programs.19. The memory manager provides the following functions:1) Shields(屏蔽) the hardware structure of all kinds of memory, providesa unified call interface2) Large Address Space In a multi process system, the total memory consumed by all processes usually exceed the total amount of physical memory. 3) Protection Prevents processes from accessing address spaces of other processes and kernel. (Isolation of virtul address space) Prevent processes from overwriting code and read-only data. 4) Memory Mapping (内存映射) Mapping the virtual address space of CPU to physical memory.5) Fairly access(公平访问) to physical memory6) Shared memory(共享内存) 20. Mapping(映射) of the virtual memory page to the physical memory page.Virtual memory: VPFN (Virtual Page Frame Number)Physical memory: PFN (Page Frame Number)the Page Tables(页表)A virtual memory address consists of two parts:one is a offset address(偏移地址), the other is a VPFN.In Figure 2.3, the virtual memory page 0 of process X maps to physical memory page 1, and the virtual memory page 1 of process Y maps to physical memory page 4.课件例题21. Demand Paging(按需装入页面) One way to save physical memory is only loading the virtual memory pages that are being used into the physical memory. When a process attempts to access a virtual memory page that is not in physical memory, the processor generates a page error to the operating system. If the virtual memory address where a page error occurs is invalid, the operating system will abort(中止) the operation of the process, to prevent other processes in the system from being damaged. If the virtual memory address where a page error occurs is valid , but the page is not in physical memory, the operating system must read the correct page from the hard disk into system memory. Linux systems use Demand Paging to load executable code into the virtual memory of a process. 22. Swapping(交换) When a process needs to load a virtual memory page into physical memory, but the memory has no free space, the operating system must discard a page in physical memory to clear the space for the virtual memory page to be loaded. Least Recently Used (LRU, 最近最少使用) “dirty pages” (脏页), swap file 23. Shared Virtual Memory(共享虚拟内存) Because of the use of virtual memory, it is easy to share memory between several processes. If you want two processes to share a physical memory page, just set their physical memory number in their page table entry to the same physical page number.24. Page Allocation and Deallocation(页的分配和回收) when a file image is transferred from disk to memory, the operating system needs to allocate physical memory pages for it. Another use of the physical page is to store the data structure needed by the kernel, for example, the page table. When running of the program is finished, the operating system needs to release the memory page. 25. Differences among malloc, vmalloc and kmalloc:1. Kmalloc and vmalloc are used to allocate kernel memory, malloc is used to allocate user memory.2. Kmalloc ensures that the allocated memory is physically continuous. Malloc and vmalloc ensure that the memory is continuous in the virtual address space3. The memory size that kmalloc can be allocated is limited, vmalloc and malloc can allocated relatively larger memory.4. Vmalloc is slower than kmalloc.26. Attention in memory application : The kernel can only allocate some predefined fixed size memory. If you request any amount of memory, it is likely that the system will allocate a little more. These predefined memory sizes are generally “slightly less than the power(幂次方) of 2” (OR is exactly the power of 2). For example, if you need a buffer of about 2000B, youd better apply for 2000B instead of 2048B. The worst case is to request memory that happens to be the power of two - the kernel allocates twice as much memory as the requested space.27. Memory Mapping(内存映射)The method of connecting the image of a file to the virtual memory address space of a process is called memory mapping.Each vm_area_struct describes the start and end locations of a processs virtual memory, the access authority(访问权) of the process, and a series of memory-related operations. When an executable image is mapped to the virtual memory address of a process, the operating system creates a series of data structures of vm_area_struct, each representing a part of the executable image. Linux systems support a variety of standard virtual memory operations, and when vm_area_struct is created, the corresponding virtual memory operations are linked to vm_area_struct. 28. File system managementthe Virtual File System(VFS, 虚拟文件系统)Virtual File System (VFS) hides the details of various hardware and provides a unified interface for all devices. Moreover, it is independent of each specific file system, and is an abstraction of various file systems. It uses super block to store the related information of file system, uses inode (索引节点)to store the physical information of file, uses dentry(目录项) to store the logical information of file.All file systems in the system, whatever type, are mounted to one directory .This directory is called mount directory(挂接目录) or mount point(挂节点). File systems organize files stored in physical drives into a tree-like directory structure.To support the virtual file system, Linux uses the concept of index node(索引节点)An index node can be used as a storage location to store all the information about an open file on disk, include total length of files in blocks unit, file offsets, and mapping between device blocks,etc. 29. EXT2 file systemData in the EXT2 file system is stored in files in the form of data blocks. These data blocks have the same size, and the size can be set at EXT2 creation time. The length of each file should be filled to multiple of the block. EXT2 describes each file in the system by using the index node (inode) data structure. Each file in the EXT2 file system has only one index node, and each index node has a unique identifier. Some main fields of the index node of EXT2:1) Mode2) Owner Information3) Size The byte size of the file.4) Timestamps(时间戳) The time of index node establishment and the last modification time of index node.5) Datablocks Pointer to the data block that stores the file described by the index node. The Superblock (超级块) stores basic information of the file system. The administrator of the file system can use the information to maintain the file system.30. Interprocess CommunicationApplication of interprocess communication: Data transmission Shared data Notification events Resource sharing Process control31. Ways of interprocess communication1) Low-level communication Mainly used for synchronization(同步), termination(终止), suspension(挂起) and other control information transmission between processes.Common low-level communication includes Signal(信号), Semaphore(信号量) . 2) High-level communication Mainly used for exchanging and sharing data blocks between processes. Common high-level communication includes PIPE(管道), MESSAGE queues(消息队列), SHARED MEMORY(共享内存), etc. 32. Pipe communication1) Types of pipe :
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 大学资料


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!