Understanding COM Suites

Source: Internet
Author: User
Tags abstract function definition object model

Jiansu

Last semester before graduating from college, internship at a company, the work needed to use some of the components provided by the operating system. At that time only know the noun, do not know what is going on, only know the internet everywhere to find someone else's source to solve their own problems; that period of time to now memories are gray, sitting in front of the computer every day, a website to find their own needs of the source code. But it's not clear what you're doing, and there's a lot of skepticism about being able to be a programmer. At the end of the internship on the train, one night, I put a "com essence of" read over more than 120 pages. When my girlfriend and I boasted that I could read more than 100 pages a night, she immediately asked me: How much do you know? I was speechless. She couldn't bear the loss and the complaining of my days, and from that time we ended the brief relationship. Until now I was wandering alone, and last week she became someone else's wife. I could not think of any way to commemorate the only relationship I have experienced so far, I and her feelings are not entirely because of the end of the COM, but because of the confusion of COM, so I went to a confused, lost, lost confidence in her before she became a pessimistic person. Write this article right as a souvenir of this feeling.

The enterprise does not stand, the cross is not good. Many maxims tell us that we must start from the basics, and the understanding of COM is the reason. When I read "COM essence" three years ago, I just had a little knowledge of the virtual function, just knowing that it was possible to achieve polymorphism. But how to achieve it is not clear. It's normal to not understand COM. Know to see Stanley B.lippman's "Inside" C + + Object Model, the memory structure of C + + has a basic understanding, I understand the meaning of the interface. This article is for beginners, by the way give you some advice, if a book you do not understand the time, you can put, first find some basic reading to see. This can take some detours less.

Don box, in the COM essentialism, says that there is a thorough understanding of interfaces, class objects and suites, so using COM does not go over the hills. If you have a deep understanding of C + +, it is not difficult to understand the interface and class objects in the COM essentialism. But the suite is a relatively abstract concept, and the book on this part of the narrative is only theoretical, not providing concrete examples, it is more difficult to understand. Here I have found some examples and their own understanding of the following summary, in order to provide beginners with some ways to get started. Gossip stop, start the text.

I. on multithreading (multithreading)

Zi Yue: Benlidas. In other words, we understand the cause of the existence of things, and naturally understand what is going on. It would be much easier if we knew the reasons for the Apartment and then understood the suite. Let's take a look, why do we need a suite? The suite is created to address the use of components in multiple threads, and first let's look at multithreading.

1. Understanding processes (processes) and threads (Threading)

Understand threads, first from the process (processes), the general description of the process is more abstract, all said that the process is a running instance of the program, the process has memory, resources. I'm here to try to explain the process with an assembler to see if I can help you get a better impression. Let's take a look at a simple assembler program (you don't understand the assembly, suggest a book to read, not a compilation, it's hard to understand the other high-level language too much).   ; assembler example
data_seg segment; Defining a data segment
N_i DW?
Data_seg ends

stack_seg segment; definition stack
DW 128 dup (0)
Tos label word
statck_seg ends

Code1 segment Define code snippet
Main proc Far
assume cs:ccode,ds;data,seg,ss:stack_seg
Start:
Move ax , Stack_seg saves the address of the defined stack segment to the SS
mov ss,ax
mov sp,offset tos; Saves the last address of the stack to the SP, the stack is

Push DS, which is accessed from bottom to top; Save the old         Data Segment
Sub Ax,ax
Push ax

mov ax,data_seg; save defined data segments to DS
mov ds,ax

Call Fact        ; Call the child function

....        ; Other operations omit
RET; return to System
Main ENDP

fact proc near; child function definition

... The concrete operation omits
ret; returns to the call
fact ENDP

Code1 ends
End Start
Example 1: Assembler structure

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.