20145311 "Information Security system Design Fundamentals" 14th Week Study Summary

Source: Internet
Author: User
Tags byte sizes

20145311 "Information Security system Design Fundamentals" The 14th Week study summary textbook Learning content Summary

1. Physical Addressing
The main memory of a computer system is organized into an array of cells consisting of m contiguous byte sizes. Each byte has a unique physical address of Pa. The address of the first byte is 0, the next byte has an address of 1, the next is 2, and so on. Given this simple structure, the most natural way for a CPU to access memory is to use physical addresses, which we call physical addressing.
2. Virtual addressing
When using virtual addressing, the CPU accesses main memory by generating a virtual address, which is converted to the appropriate physical address before being sent to the memory. The task of translating a virtual address into a physical address is called address translation.
The dedicated hardware called the Memory management unit on the CPU chip uses the query table stored in main memory to dynamically translate the virtual address, and the contents of the table are managed by the operating system.

Three important capabilities of virtual memory:

它将主存看成是一个存储在磁盘上的地址空间的高速缓存,在主存中只保存活动区域,并根据需要在磁盘和主存之间来回传送数据,通过这种方式,高效的使用了主存。它为每个进程提供了一致的地址空间,从而简化了存储器管理。它保护了每个进程的地址空间不被其他进程破坏

The basic idea of virtual storage: Allow each data object to have multiple independent addresses, each of which is selected from a different address space

Virtual memory as a tool for memory management

操作系统为每个进程提供了一个独立的页表,也就是一个独立的虚拟地址空间。多个虚拟页面可以映射到同一个共享物理页面上。存储器映射:将一组连续的虚拟页映射到任意一个文件中的任意位置的表示法。按需页面调度和独立的虚拟地址空间的结合简化了链接和加载、代码和数据共享,以及应用程序的存储器分配。    简化链接:独立的地址空间允许每个进程的存储器映像使用相同的基本格式,而不管代码和数据实际存放在物理存储器的何处。    简化加载:虚拟存储器使得容易想存储器中加载可执行文件和共享文件对象。    简化共享:独立地址空间为操作系统提供了一个管理用户进程和操作系统自身之间共享的一致机制。    简化存储器分配:虚拟存储器为向用户进程提供一个简单的分配额外存储器的机制。

Address Translation:

1. When the page hits, the CPU executes the steps:

第一步:处理器生成一个虚拟地址,并把它传送给MMU第二步:MMU生成PTE地址,并从高速缓存/主存请求得到他第三步:高速缓存/主存向MMU返回PTE第四步:MMU构造物理地址,并把它传送给高速缓存/主存第五步:高速缓存/主存返回所请求的数据字给处理器

2. Processing pages, requiring hardware and operating system collaboration to complete

第一步到第三步同上第四步:PTE中的有效位是0,MMU触发异常,传递CPU中的控制到操作系统内核中的缺页异常处理程序第五步:程序确定物理存储器中的牺牲页,如果页面被修改,则换出到磁盘第六步:程序页面调入新的页面,并更新存储器中的PTE第七步:程序返回到原来的进程,再次执行导致缺页的指令

3. Combining cache and virtual memory

The main idea: Address translation occurs before the cache is found

4. Using TLB to accelerate address translation

Translation fallback buffer tlb: is a small, virtual-addressing cache in which each row holds a block of a single pte with a high degree of connectivity

5. The usual way to compress a page table is to use a hierarchical page table, which reduces the memory requirements in two ways:

第一点:节约,如果一级页表中的PTE是空的,那么相应的二级页表就不会存在第二点:减压,只有一级页表存在主存中,只有经常使用的二级页表才需要缓存在主存中

Linux Virtual storage: Each existing virtual page exists in a zone, and a virtual page that is not part of a zone does not exist and cannot be referenced by the process. A specific area structure contains the fields:

(1) Vm_start: Point at the beginning of the area. (2) Vm_end: Point at the end of the area. (3) Vm_prot: Describes the read and Write permission permissions for all pages contained within this area. (4) Vm_flags: Describes whether the page in this area is shared with other processes, or whether the process is private (and some other information is also described). (5) Vm_next: Point to the next area structure in the list.

Linux pages exception handling:

Fragmentation: Although there is unused memory, it cannot be used to satisfy the allocation request. Internal fragmentation: Occurs when an allocated block is larger than the payload and is easily quantified. External fragmentation: Occurs when free memory is aggregated enough to satisfy an allocation request, but there is not a single space block sufficient to handle this request. Difficult to quantify, unpredictable.

The garbage collector is a dynamic storage allocator, and the auto-release program is not in the required allocated block Makr&sweep The garbage collector has the tagging phase and the purge phase

Mark&sweep garbage collector
    • The Mark&sweep garbage collector consists of a tagging phase and a purge phase, which marks the root node for all the accessible and assigned successors, and the purge phase releases each unmarked allocated block.

    • The following functions are used in the description of Mark&sweep:
      • PTR isptr (PTR p): if p points to a word in an allocated block, it returns a pointer B to the starting position of the block, otherwise null is returned.
      • int blockmarked (PTR b): Returns TRUE if Block B has already been marked.
      • int blockallocated (PTR b): Returns TRUE if Block B is assigned.
      • void Markblock (PTR b): Tag block B.
      • int length (PTR b): Returns the length in words of block B (excluding the head).
      • void Unmarkblock (PTR b): Changes the state of block B from marked to unmarked.
      • PTR nextblock (PTR b): Returns the successor of Block B in the heap.

Common memory-related errors in C programs indirectly refer to bad pointers: there is a large hole in the virtual address space of the process, no mapping to any meaningful data, and if you attempt to reference a pointer to these holes, the operating system terminates the program with a segment exception. Read uninitialized memory allows stack buffer overflow to cause dislocation error misunderstanding pointer operation referencing a non-existent variable

This week code hosting other (sentiment, thinking, etc., optional)

This chapter is about virtual memory, which is an important abstraction of the computer, which abstracts the physical storage space in the computer.

Of course, this can also lead to some errors, such as the above mentioned in the C language of some errors, after understanding this knowledge can be better to help us to avoid some of the errors caused by storage

Learning progress Bar new/cumulative) /cumulative)
lines of code (new/cumulative) Blog Volume (Learning time (new
Goal 5000 rows 30 Articles 400 hours
First week 100/100 1/2 10/10
Second week 150/200 2/4 8/18
Third week 200/250 1/5 5/23
Week Five 50/300 1/6 9/32
Week Six 20/320 1/7 8/40
Seventh Week 20/340 1/8 6/46
Eighth Week 60/400 2/10 6/52
Nineth Week 80/480 1/11 8/60
Tenth Week 60/540 2/13 6/66
11th Week 80/620 1/14 6/72
12th Week 50/670 1/15 5/77
13th Week 50/720 1/16 6/83
14th Week 0/720 1/17 5/88
Resources
        • "In-depth understanding of computer system V2" Learning Guide
        • Teaching material reading and weekly exam focus
        • 2016-2017-1 the teaching process of the basic design of information security system
        • ...

20145311 "Information Security system Design Fundamentals" 14th Week Study Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.