1 00:00:00,090 --> 00:00:05,650 So in this video, we're creating a new feature called Run the Shared Code that is generated from Amazon 2 00:00:05,670 --> 00:00:11,940 rental offer that will be using the virtual analog function and also virtual free function. 3 00:00:12,600 --> 00:00:17,870 So let's take a look at this virtual log function and you'd be returning in the candidate. 4 00:00:20,400 --> 00:00:31,200 So Torreira creates a region in our term memory space so we can put our data in. 5 00:00:32,610 --> 00:00:36,210 So reserves commit our to the state of origin of pages. 6 00:00:38,370 --> 00:00:44,340 So our virtual address will be a map of the via page tables. 7 00:00:45,360 --> 00:00:51,990 So we'll be creating a region of space to hold our shared code in our own process. 8 00:00:52,740 --> 00:01:04,740 And let's see the parameters of this now return by the pointer to the starting block of our region. 9 00:01:06,700 --> 00:01:11,890 So from this point that we can allocate the share into this region. 10 00:01:12,790 --> 00:01:15,280 And the first one is an optional. 11 00:01:15,280 --> 00:01:21,250 When you are running this function for the first time, you can pass null for this parameter. 12 00:01:21,730 --> 00:01:29,560 And that means we are allowing the operating system to choose a particular free region of this. 13 00:01:29,560 --> 00:01:32,210 Much I want our sites who are looking for us. 14 00:01:33,070 --> 00:01:37,450 So the second parameter is the size, size of the block. 15 00:01:37,450 --> 00:01:41,350 We want to allocate, say, 100 bytes, 200 divides, etc.. 16 00:01:42,490 --> 00:01:46,840 And the third parameter is allocation type and will be using the commit. 17 00:01:47,080 --> 00:01:48,660 So this commit. 18 00:01:48,670 --> 00:01:56,980 But what it does is we are telling this memory manager to allocate some space but do not assign any 19 00:01:57,220 --> 00:01:57,940 directly. 20 00:01:59,080 --> 00:02:07,060 So whenever we try to access for the first time, it will create an image file and then operating system 21 00:02:07,060 --> 00:02:12,580 will try to assign the this block of region. 22 00:02:12,760 --> 00:02:17,430 So until then, there will be no memory for aggregated one. 23 00:02:17,740 --> 00:02:20,020 This is called On-Demand paging. 24 00:02:20,140 --> 00:02:25,510 Whenever you access, then only the memory will be converted for you. 25 00:02:27,940 --> 00:02:32,950 And the next parameter is the type of prediction we want for our memory. 26 00:02:33,550 --> 00:02:36,620 And Picasso opened this one memory production constant. 27 00:02:37,120 --> 00:02:41,500 So you can finally see and separate the building. 28 00:02:42,310 --> 00:02:43,780 So we are giving the permission. 29 00:02:43,790 --> 00:02:47,230 So we'll be using this page, execute, rewrite. 30 00:02:47,980 --> 00:02:50,930 And I have already copied all of this content values. 31 00:02:50,950 --> 00:02:53,320 We are going to commit parity. 32 00:02:53,320 --> 00:02:53,710 Right? 33 00:02:54,740 --> 00:02:55,100 Right. 34 00:02:55,200 --> 00:02:55,690 Execute. 35 00:02:55,690 --> 00:02:55,930 Right. 36 00:03:04,830 --> 00:03:10,440 So I also created the share recorder using this compendium as a film so it would pop up the character 37 00:03:10,440 --> 00:03:12,180 and the tape is C-sharp. 38 00:03:12,510 --> 00:03:16,560 Now, if you expand this and here you can see the circle from Amazon. 39 00:03:17,130 --> 00:03:18,870 So it's it's not by the. 40 00:03:20,370 --> 00:03:22,440 So let's define our functions. 41 00:03:23,650 --> 00:03:25,050 What function? 42 00:03:37,840 --> 00:03:43,360 So the return type is the pointer to the starting address of the our memory region. 43 00:03:48,460 --> 00:03:50,920 And the first barometer is the pointer. 44 00:03:52,970 --> 00:03:55,080 To the address where you want to create. 45 00:03:55,410 --> 00:03:57,520 So for the first time, we'll be sending the. 46 00:03:59,930 --> 00:04:00,670 And the size. 47 00:04:00,830 --> 00:04:08,630 So it's obviously going to be in Annotation Bay, which is the unit that we do. 48 00:04:11,920 --> 00:04:13,120 And the production they. 49 00:04:17,170 --> 00:04:21,130 It's also the great this virtual free. 50 00:04:23,260 --> 00:04:28,810 So virtual free will freedom of religion declared by that virtual function. 51 00:04:29,530 --> 00:04:36,850 So in this this is compulsory because we need to actually if you are calling this function when you 52 00:04:36,910 --> 00:04:40,720 actually free something and this is a mandatory parameter. 53 00:04:42,590 --> 00:04:45,740 The pointer to the base are those are the region pages to be free. 54 00:05:18,260 --> 00:05:24,500 And the second is the size of the region we want to release are becoming. 55 00:05:27,360 --> 00:05:29,700 And the third type is, uh. 56 00:05:31,700 --> 00:05:32,540 The type of. 57 00:05:34,530 --> 00:05:36,390 We want to free the region. 58 00:05:37,550 --> 00:05:39,320 So our functions has been declared. 59 00:05:47,370 --> 00:05:49,850 So I think we are starting out. 60 00:05:49,870 --> 00:05:57,750 So at this starting point, our points go down starting at the start of our memory and what you are 61 00:05:57,770 --> 00:05:58,140 allowed. 62 00:05:58,530 --> 00:06:03,840 So we are sending the first two parameters and all. 63 00:06:05,350 --> 00:06:08,950 Because we don't know where there is a free space in the memory. 64 00:06:09,850 --> 00:06:12,730 So this will be decided by the operating system. 65 00:06:12,730 --> 00:06:13,750 And the second one is. 66 00:06:16,770 --> 00:06:17,100 Commit. 67 00:06:20,560 --> 00:06:21,880 So there is a size 18. 68 00:06:22,120 --> 00:06:27,980 So size the size of this one use that you. 69 00:06:30,440 --> 00:06:35,570 Cheryl Cole says the course to begin to buffer not relent. 70 00:06:40,930 --> 00:06:41,440 Come on. 71 00:06:41,800 --> 00:06:49,420 And the third barometer is adaptation by committee and the production dynamics page. 72 00:06:50,350 --> 00:06:50,620 Right. 73 00:06:55,720 --> 00:07:01,880 So let's also create what will three of the starting point are. 74 00:07:03,470 --> 00:07:08,120 And how much of you want to free that is the length of this circle. 75 00:07:09,530 --> 00:07:12,110 Jericho The size and the free time is. 76 00:07:21,340 --> 00:07:23,140 So this will return. 77 00:07:23,530 --> 00:07:24,160 Brilliant. 78 00:07:26,200 --> 00:07:34,180 So now we have allocated some space and we are freeing that space between these events. 79 00:07:34,190 --> 00:07:38,200 We need to write our circle. 80 00:07:40,530 --> 00:07:41,520 Well this region. 81 00:07:41,550 --> 00:07:51,770 So we can do that using the RTA more memory so we can use this article more memory. 82 00:07:51,810 --> 00:07:59,220 So the first final destination and second parameter resource, which would be the pointer to the Chicago 83 00:07:59,220 --> 00:07:59,550 area. 84 00:08:00,360 --> 00:08:03,120 And this one is definitely the pointer. 85 00:08:03,570 --> 00:08:08,340 So we can also use a marshall not copy. 86 00:08:08,970 --> 00:08:11,160 So this is a very simple one to use. 87 00:08:11,670 --> 00:08:17,880 The first parameter is the better, which is my above, and the second is starting index. 88 00:08:18,150 --> 00:08:19,350 So zero. 89 00:08:19,800 --> 00:08:22,890 And the third one is the destination where we want to write. 90 00:08:24,120 --> 00:08:33,080 That is our starting point and the length of this area we want to write that is shall go to things. 91 00:08:35,620 --> 00:08:41,470 Now we have successfully returned our record to this at this location starting point. 92 00:08:41,510 --> 00:08:45,620 And so how we are going to execute is using that these are delegates. 93 00:08:45,620 --> 00:08:50,200 So these are delegates are kind of like function binders. 94 00:08:51,260 --> 00:08:53,690 So I'll be showing your example for this. 95 00:08:53,990 --> 00:08:57,860 So there is a function called test that will print something. 96 00:08:58,340 --> 00:09:02,000 Now I'm going to declare public Medicare. 97 00:09:06,020 --> 00:09:06,980 Wide example. 98 00:09:08,360 --> 00:09:15,500 So these benefits are, uh, like function binders and they can execute a bunch of functions whenever 99 00:09:15,500 --> 00:09:17,270 there is even has occurred. 100 00:09:17,510 --> 00:09:24,620 Suppose if there is an event occurred, you want to run a function, so you can obviously call one function. 101 00:09:24,620 --> 00:09:30,980 If you want to execute any functions for the same event, you need to say one, let's do the string 102 00:09:30,980 --> 00:09:31,330 setter. 103 00:09:31,700 --> 00:09:37,280 So instead of that, what you can do is you can group a bunch of functions into this delegate so it 104 00:09:37,280 --> 00:09:38,120 can execute. 105 00:09:38,450 --> 00:09:42,350 You can just execute this delegate and the function gets executed. 106 00:09:44,310 --> 00:09:45,130 So, uh. 107 00:09:45,180 --> 00:09:47,390 No, I can, uh. 108 00:09:49,980 --> 00:09:51,360 See sample. 109 00:10:01,380 --> 00:10:03,020 Simple as equal to. 110 00:10:06,120 --> 00:10:07,110 Program got. 111 00:10:10,170 --> 00:10:11,220 Program darkish. 112 00:10:11,390 --> 00:10:13,230 So the function is the. 113 00:10:16,640 --> 00:10:17,000 Yes. 114 00:10:17,000 --> 00:10:18,590 That is a function of putting something. 115 00:10:19,160 --> 00:10:20,770 Now I can just call this. 116 00:10:26,420 --> 00:10:27,260 So to move this. 117 00:10:28,340 --> 00:10:30,440 So now if I go and run this. 118 00:10:36,600 --> 00:10:41,820 So now you can see we are printing, we are executing that function, using this delegate. 119 00:10:42,570 --> 00:10:50,220 So you can also say yes plus is equal to if you have another function, you can also program the test. 120 00:10:51,420 --> 00:10:52,770 Now you can call this. 121 00:10:55,510 --> 00:10:56,400 It's going to cost you. 122 00:10:57,430 --> 00:11:03,490 So that's how you can change multiple functions and execute this delegate whenever there is an even 123 00:11:03,490 --> 00:11:03,910 better. 124 00:11:09,930 --> 00:11:12,360 So now we have this delegate sample. 125 00:11:12,360 --> 00:11:20,190 Right now, what we're going to do is we are going to fetch the content at the starting point and execute 126 00:11:20,190 --> 00:11:21,330 that as a function. 127 00:11:23,240 --> 00:11:25,160 So we can do that using martial art. 128 00:11:26,020 --> 00:11:27,740 Get delegate for the function. 129 00:11:28,970 --> 00:11:31,280 So we're getting the delegate for this function. 130 00:11:33,530 --> 00:11:35,120 And the parameters are. 131 00:11:37,640 --> 00:11:39,070 Starting up. 132 00:11:40,280 --> 00:11:43,790 And then a Chinese type of sample. 133 00:11:44,360 --> 00:11:46,070 So it's just nothing. 134 00:11:48,270 --> 00:11:52,170 So this will give you that sample. 135 00:11:52,200 --> 00:11:52,470 Yes. 136 00:11:52,590 --> 00:11:53,280 Equals two. 137 00:11:53,910 --> 00:11:56,940 And we need to catch to this sample now. 138 00:11:58,040 --> 00:12:06,350 We allocated this brigade to execute their function located at this starting point of. 139 00:12:07,870 --> 00:12:17,500 So now I can simply Correa's and the decor at the starting point will be treated as a function and get 140 00:12:17,500 --> 00:12:18,130 executed. 141 00:12:18,820 --> 00:12:19,960 Now let's go and run this. 142 00:12:21,270 --> 00:12:22,950 And here you can see we got that. 143 00:12:25,740 --> 00:12:31,350 So this is how you run the circle, using the C-sharp, using the delegates and windows functions.