Windows Basics Review

Source: Internet
Author: User

1.1. The command prompt (console) is a software: If your software is set up as a console user interface, window will run your software with a command prompt.

1.2, if it is a window, Windows will not come to you, just load directly.

1.3, hPrevInstance: Never use in your program.

1.4. Process instance handle: Every execution or DLL file loaded into the address space is given a unique instance handle.

1.5, process at the time of death we need to do some recycling and cleaning things.

1.6. A kernel object leak is a much more troublesome thing than a memory leak. Memory leaks can be resolved by shutting down the process, and the kernel leaks can only be resolved by restarting the operating system.

1.7, using exitprocess and so on, similar functions to force the end of the process is not wise, which will make the resources can not be recycled.

1.8, Process permissions:

1.9, the process is completely closed. Open some interfaces.

1.10. UAC: Permissions with the filter table. Permission elevation can now be performed only on the boundaries of the program.

1.11, UAC will maximize to protect the user's security.

1.12, any process is composed of many modules.

1.13, Process: process kernel space, address space.

1.14, the main function is also a thread function.

1.15, the process dies all the threads of the current process are exited.

1.16, the process ends the main thread exits, the main thread exits all the child threads.

1.17. The WaitForSingleObject function waits for the end of the child thread. Only after executing the code after the main thread will go extinct. Ensures that the child threads are able to exit normally.

1.18, in the multi-threaded parameters when the special delivery must pay attention to. It is possible that the child thread is still using the main thread's push stack when the main thread exits. Static members, or all variables, can solve this problem.

1.19. The ExitThread function immediately ends the current thread: the stack that belongs to the current thread is destroyed, but the destructor is not called. This can easily cause a memory leak.

1.20, _beginthreadex (), the creation of new threads is created using this function process. Because the function is more secure than the CreateThread. and more portable.

1.21, _beginthread (), this function does not create a new stack, so do not use.

1.22, SuspendThread (hthread), the function will make the thread pause count plus one (Suspend: pause), when the thread pause count is not 0, the thread will not enter the CPU scheduling.

1.23, ResumeThread (hthread), and this function causes the pause count to be reduced by one (resume: resume).

1.24. Thread hangs should not occur in a good program: Because thread hangs is non-thread safe.

1.25, wait, Hibernate: The thread will discard the time slice.

1.26. The SwitchToThread () function discards the time slice of the current thread and then gives the remaining time slices to the high-hungry threads to execute.

1.27.

=&context); _tprintf (TEXT ("ebp:0x%x, esp:0x%x, eip:0x%x\r\n"), Context. EBP, context. ESP, context. EIP); // Select Output

1.28. Global variables are non-thread-safe, and global variables can cause a variety of problems in multithreaded programming.

1.29, the Lock API (atomic operation): InterlockedExchange function, return the previous value of the parameter.

1.30, the so-called atomic operation is a sentence of the assembly code.

1.31, locking is equivalent to making multithreading become a single thread.

1.32. When two or more threads have data sharing, try to make them run under the same CPU.

1.33, Rotary Lock: In a while in a continuous cycle, until allowed to enter the area.

1.34, EnterCriticalSection (&gcs), this function into the critical section, and the dead loop somewhat similar, the main purpose is to block other threads, do not let other threads into the current area

To ensure that only one thread is accessing the current code at the same time.

1.35, data synchronization: In order to avoid access to the same resource when an error occurs, resulting in the value obtained is wrong

1.36. Lock:
1.36.1,

 while (InterlockedExchange (long// waits in the while loop.) Wait until the executable state.  {Sleep (1);} // code. InterlockedExchange ((long*) &busing, FALSE);

1.36.2,

Critical_section GCS; // boundary zone, key segment. initializecriticalsection (&gcs); // initialized.  deletecriticalsection (// call at end of process, delete// Thread:// Enter the critical section // code. releasecriticalsection (&gcs); // Exit critical Section

1.36.3,

SRWLOCK GSRW;//_slim LockInitializesrwlock (&GSRW);//Initialize, this only initializes without delete. //threads, divided into exclusive and shared locks://Exclusive lock mode:Acquiresrwlockexclusive (&GSRW);//code.releasesrwlockexclusive (&GSRW);//shared lock mode:Acquiresrwlockshared (&GSRW);//code.releasesrwlockshared (&GSRW);//the monopoly and sharing here requires that a thread that cares about an exclusive lock lock will have to exit all of the threads that are allowed to lock all of a shared lock mode. //When a thread that is locked with a shared lock is executing, the thread that exclusively locks the lock is not executed. 

Windows Basics Review

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.