20140829 direct insertion sorting

Source: Internet
Author: User
#include<stdio.h>void InsertSort(int a[],int len){    int temp=0,i,j;    for(i=1;i<len;i++)    {        temp=a[i];        for(j=i-1;j>=0&&temp<a[j];j--)        {            a[j+1]=a[j];        }        a[j+1]=temp;    }}Pint main(){    int a[]={3,2,5,7,1,8};    int len=sizeof(a)/4;    InsertSort(a,len);    }

2. Memory Address Space

For example, if you want to output a piece of information to the monitor, you must write the information to the video memory before the video card can output it to the monitor. To write data to the video memory, you must know the address of the video memory in the memory address space.

For the CPU, all the storage units in the system are in a unified logical memory, and its capacity is limited by the CPU addressing capability. This logical memory is what we call the memory address space.

Bytes

3. multi-thread understanding

Is the computing thread enabled in the background? For example, I open a game, a thunder, a browser, and some anti-virus software, but there is only one game window on the desktop, and the others are minimized.

 

What you are talking about is multi-process. You can understand that an application (software) is a process and the thread is in the process. A process can have one or more threads. It looks like an audio playing software that displays the lyrics, audio bars, and songs.

4. Windows Memory Management Knowledge

1. The physical memory of the machine is composed of two parts. Part ofPrimary Memory RAM, That is, the size of our memory stick; the other part isVirtual MemoryIt exists in the form of page files on the machine's hard disk.

2. Each process has its own virtual address space. For 32-bit addressing machines, the size of this virtual space is 4 GB. Now we use 4 GB machines.

3. the 4 GB virtual address space of a process can be divided into several parts. The actual private space of a process is less than 2 GB (this address space is called "user-mode partitioning "), the remaining 2 GB space is for the operating system and is shared by all processes. (Refer to Windows core programming chapter 13)

4. "allocate memory" for the process. This concept can be refined: "reserve an address space", "Submit a memory space", and "map the memory space to the primary memory ". In a program, the address we usually access must be the address space reserved and submitted in the process address space.

4.1 "retain an address space ":That is, a segment of address space is reserved from the 4 GB address space of the process.This process is completed using the virtualalloc function and the allocation type parameter is set to mem_reserve. The starting address of this space must be an integer multiple of the system allocation granularity, And the size must be an integer multiple of the system page size.

4.2 "Submit a piece of memory space ":That is, the address space reserved by the process is mapped to the physical memory of the machine.Note that the so-called physical memory is generally not the master memory of the machine, but the virtual memory of the machine. This process is also completed with virtualalloc, but the allocation type parameter is set to mem_commit. The starting address and size of this space must be an integer multiple of the page size. This process correspondsThe submitted region is mapped to the virtual memory of the machine..

4.3 "ing memory space to primary memory": This is very important, and the operating system alwaysThe corresponding page is loaded to the primary storage only when the page submitted by the process is accessed.And modify the address space ing of the corresponding page of the process. At this time, the corresponding region of the process address space corresponds to the master memory on the machine.

20140829 direct insertion sorting

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.