So in this video, we're creating a new feature called Run the Shared Code that is generated from Amazon
rental offer that will be using the virtual analog function and also virtual free function.
So let's take a look at this virtual log function and you'd be returning in the candidate.
So Torreira creates a region in our term memory space so we can put our data in.
So reserves commit our to the state of origin of pages.
So our virtual address will be a map of the via page tables.
So we'll be creating a region of space to hold our shared code in our own process.
And let's see the parameters of this now return by the pointer to the starting block of our region.
So from this point that we can allocate the share into this region.
And the first one is an optional.
When you are running this function for the first time, you can pass null for this parameter.
And that means we are allowing the operating system to choose a particular free region of this.
Much I want our sites who are looking for us.
So the second parameter is the size, size of the block.
We want to allocate, say, 100 bytes, 200 divides, etc..
And the third parameter is allocation type and will be using the commit.
So this commit.
But what it does is we are telling this memory manager to allocate some space but do not assign any
directly.
So whenever we try to access for the first time, it will create an image file and then operating system
will try to assign the this block of region.
So until then, there will be no memory for aggregated one.
This is called On-Demand paging.
Whenever you access, then only the memory will be converted for you.
And the next parameter is the type of prediction we want for our memory.
And Picasso opened this one memory production constant.
So you can finally see and separate the building.
So we are giving the permission.
So we'll be using this page, execute, rewrite.
And I have already copied all of this content values.
We are going to commit parity.
Right?
Right.
Execute.
Right.
So I also created the share recorder using this compendium as a film so it would pop up the character
and the tape is C-sharp.
Now, if you expand this and here you can see the circle from Amazon.
So it's it's not by the.
So let's define our functions.
What function?
So the return type is the pointer to the starting address of the our memory region.
And the first barometer is the pointer.
To the address where you want to create.
So for the first time, we'll be sending the.
And the size.
So it's obviously going to be in Annotation Bay, which is the unit that we do.
And the production they.
It's also the great this virtual free.
So virtual free will freedom of religion declared by that virtual function.
So in this this is compulsory because we need to actually if you are calling this function when you
actually free something and this is a mandatory parameter.
The pointer to the base are those are the region pages to be free.
And the second is the size of the region we want to release are becoming.
And the third type is, uh.
The type of.
We want to free the region.
So our functions has been declared.
So I think we are starting out.
So at this starting point, our points go down starting at the start of our memory and what you are
allowed.
So we are sending the first two parameters and all.
Because we don't know where there is a free space in the memory.
So this will be decided by the operating system.
And the second one is.
Commit.
So there is a size 18.
So size the size of this one use that you.
Cheryl Cole says the course to begin to buffer not relent.
Come on.
And the third barometer is adaptation by committee and the production dynamics page.
Right.
So let's also create what will three of the starting point are.
And how much of you want to free that is the length of this circle.
Jericho The size and the free time is.
So this will return.
Brilliant.
So now we have allocated some space and we are freeing that space between these events.
We need to write our circle.
Well this region.
So we can do that using the RTA more memory so we can use this article more memory.
So the first final destination and second parameter resource, which would be the pointer to the Chicago
area.
And this one is definitely the pointer.
So we can also use a marshall not copy.
So this is a very simple one to use.
The first parameter is the better, which is my above, and the second is starting index.
So zero.
And the third one is the destination where we want to write.
That is our starting point and the length of this area we want to write that is shall go to things.
Now we have successfully returned our record to this at this location starting point.
And so how we are going to execute is using that these are delegates.
So these are delegates are kind of like function binders.
So I'll be showing your example for this.
So there is a function called test that will print something.
Now I'm going to declare public Medicare.
Wide example.
So these benefits are, uh, like function binders and they can execute a bunch of functions whenever
there is even has occurred.
Suppose if there is an event occurred, you want to run a function, so you can obviously call one function.
If you want to execute any functions for the same event, you need to say one, let's do the string
setter.
So instead of that, what you can do is you can group a bunch of functions into this delegate so it
can execute.
You can just execute this delegate and the function gets executed.
So, uh.
No, I can, uh.
See sample.
Simple as equal to.
Program got.
Program darkish.
So the function is the.
Yes.
That is a function of putting something.
Now I can just call this.
So to move this.
So now if I go and run this.
So now you can see we are printing, we are executing that function, using this delegate.
So you can also say yes plus is equal to if you have another function, you can also program the test.
Now you can call this.
It's going to cost you.
So that's how you can change multiple functions and execute this delegate whenever there is an even
better.
So now we have this delegate sample.
Right now, what we're going to do is we are going to fetch the content at the starting point and execute
that as a function.
So we can do that using martial art.
Get delegate for the function.
So we're getting the delegate for this function.
And the parameters are.
Starting up.
And then a Chinese type of sample.
So it's just nothing.
So this will give you that sample.
Yes.
Equals two.
And we need to catch to this sample now.
We allocated this brigade to execute their function located at this starting point of.
So now I can simply Correa's and the decor at the starting point will be treated as a function and get
executed.
Now let's go and run this.
And here you can see we got that.
So this is how you run the circle, using the C-sharp, using the delegates and windows functions.