Okay, we're here to talk about how OpenShift is Kubernetes. Let's go and dive in. Actually, the first thing I'll show you is Minikube, because let's go ahead and set the baseline here, like kubectl version as an example, and then kubectl get nodes. There we go. Single node for Minikube, kubectl get CRDs, and of course, there are no CRDs in Minikube, because it is a bare bones Kubernetes. So let's go now and flip over to an OpenShift, right? I have my OpenShift running on Google Cloud Platform. Let's do it and check the version real fast. Fantastic. It looks like it's 116 as well. You can see I have three master nodes and three worker nodes, because you want a nice, highly available environment. And then if I say kubectl get CRDs, all namespaces over here, we will see there's a bunch of custom resource definitions, of many, many extensions out of the box. Let's explore that a little bit more. Get pods, all namespaces. You can see there's a bunch of pods that are coming with an OpenShift right out of the gate. So if I say grep, and let's look for SDN, Software Defined Networking. We have a Software Defined Networking solution. Maybe if I look at monitoring, you'll see things like Thanos, Prometheus, Grafana, all of that out of the box.  But for now, let's just go and deploy an application. Let's just see how that checks out. kubectl, create namespace. Let me create the namespace and what is called this thing, stuff. Yep, that looks good. Create stuff. And then also I need to, I was going to make that the default namespace. So kubectl config, okay. Set context. We want to basically set the context here so that we can, let me, whoop, let me type that correctly. Set context. Current. And, and we want to say dash dash namespace stuff. Now this is of course a lot to type in this case and I often forget it. But there's a nice little command for open, in the case of OpenShift OC command line tool. I could have just said stuff as an example. And then it makes that a little bit easier to be on the right thing in this case. Okay, so kubectl get pods. There should be no pods running. Nothing really here at all. kubectl get all. But let's go ahead and actually fire up something at this point. In this directory, you can see that I have a deployment, a service, a ingress. Let's go ahead and deploy those. So kubectl apply dash f. And let's go ahead and deploy, run my deployment. And so that'll get going. And there we go. kubectl get events. If we look at our event stream, we should see that the pod is being scheduled. It should do its pulling and pulled. But let's look at that deployment while we're waiting for the image to be pulled. So look at it real quick. You can see basically it has my spring boot image coming from Kwi.io. I did set it to all ways so we can always see the image pull. And some configuration request and live and readiness probe. Pretty standard stuff there. And let me go back and check my events to see how things look over here. All right, we see the pulling. We see the pulled. Get pods. Let's see if our pod is up. Okay, let's see. Fantastic. Let's go see if our spring boot application is alive and well. So kubectl exec. We're going to just dive right in and check it out. So there we go. Curl localhost 8080. Oh, there it is. My little spring boot application, alive and happy. So that is fantastic stuff right there. So let me exit out of there. And let's go ahead and add now our service. We have that file down here as well. Ply-f and then the service. There we go. Get that service created. And then let's go ahead and get the ingress created. So dash f ingress. Get that ingress up and running. Let's kubectl get the ingress. See what it looks like. And there we go. So now I should be able to just curl and curl that guy. Let's see, curl. There we go. Fantastic. So if I say while true, do curl, paste that in. Let's go to sleep. And then a done. We should just better hit it, right? So there we go. We're actually interacting with the application. Now all of this, of course, could have been done with the console. So if I come back here to the console and maybe go to my developer mode and go check out the project called stuff. Okay. That's the one we just created. So if I come over here, I can see that there's those pods. And if I actually want to crank up the replicas, I could just click the button here also. So I could have done the replica thing if I wanted to. And we can kind of check that out and see that now we're going to have additional pods. Additional pods. Let's do watch kubectl get pods. Spinny life. Based on that, you can see they're going through their container creating phase and making sure that it does the pulling and the pulled and gets those things loaded. And then, of course, once they're there, they're going to be part of the load balancers example. So those guys will get loaded here in a moment as my system is very busy at this time. But we'll let that continue to occur. And I do want to show you one more little thing. So while we're waiting for that, let's do this real quick. kubectl edit. Let me double check something. Edit kubectl editor. Yeah. Okay. It's set correctly. kubectl edit deployment. My app. Okay. Let's, uh, there we go. We're starting to see the load balancer work, but I'm going to edit the deployment and pull that out real quick. So here it comes. All right. Now it's mapped to Visual Studio Code. I'm going to edit my deployment by just simply doing this with a, I'm going to just map it to a whole different image. Quarkus demo. 1.0.0. Hit save and close. And then let it do its rolling update. So basically it's got to go out there now and make that adjustment to that new image doing a rolling update across the three pods that we had before. So in this case, you kind of see how the deployment was behaving, how the replica set behaves, because again, this is all standard Kubernetes behavior, nothing unusual in this case. So we'll just wait a second for it to finish. And there you go. You kind of see now that the supersonic subatomic Java image is now right in play. And we didn't actually see any errors or anything like that because the rolling update is nice and smooth based on our liveness probe and render's probe. But that is open shift is Kubernetes.


Hi, I am Dr. Sachit Abraham, Consultant Dematologist at Manipal Hospital in Bangalore. Acne is a combination of many different factors. One of the main reasons for acne is having a genetic tendency to get the problem. And it also involves certain other factors which aggravate the problem, like certain drugs can aggravate the problem or certain hormonal conditions. And basically it is a multi-factorial reason. There are many different reasons. One is genetics, environmental factors, hormones, drugs, stress, all these play a role to produce acne. But basically the fundamental thing is that person should have a genetic tendency to get the problem.


Hello people of the internet, my name is Johnny and welcome back finally to yet another Docko FNAF song reaction video. Man, it feels like it has been so, so long since we last reacted to a song by Docko. I'm pretty sure his last song came out in April, but Fetch, which was his last Fazbear Fright song, came out all the way back in December. So yeah, it's been a little bit. But thankfully we're here today finally with the lonely, fruity Fazbear Fright song that just came out today. From what I've heard with the previews, it sounds like an absolute bop, so I'm really hoping that the full song is still a bop. And also the animation. I absolutely adored the animation in Fetch, so I'm hoping Lonely Freddy can at least live up to and maybe exceed the animation of Fetch. Also quickly before I hop into it, I'll make a whole separate video talking about it probably tomorrow, but you may have seen a alleged leak about Security Breach and the release date of the game. Mr. Wall just recently made a tweet basically de-confirming that as the release date. So you don't gotta spam the comments, don't worry, the release date is a old placeholder date and again, I'll talk about it in more detail in a future video. But for now, let's hop into Lonely Freddy because I am very excited to hear the song. So without further ado, this is FNAF, Lonely Freddy song lyrics video by Docko and the one and only legendary D-Houster. Let's go. Lonely Freddy. I love the, uh, Unwithered Withers. I believe this is Alec, or Alex, Alec. It's a nice calm beat right now, but I do know that it picks up speed a bit later on. It's really calming though. I haven't actually read Lonely Freddy, but I know the basic story. There you go, he buys the toy. This is really nice. Yeah, and there's Lonely Freddy.  He also looks so cute yet so terrifying. Oh, oh, creepy. Oh my god. Dude, this animation is sick. That was insane. I love that. Dude, Docko, you're hitting those notes my man. I like this song. This is really nice. Dude, his animation is so well done. Mad drops. Say it dude. Oh dude, that's terrifying. Is that it? Felt a bit short, but very enjoyable. I think that's it boys. Damn, I loved that. That was nice. That was really sweet. Oh, what's going on? Oh, credits. Let's go Russell, my man. Yeah, I mean, this was amazing. Right, I know a lot of people probably won't like the song because it's very different from what we usually have, but I find it quite calming. I think it was really sweet, really nice. And Docko, like, dude, he's evolved so much as a singer. Nintendo Switch. I don't know how he's grown and evolved so much with singing, but he's hitting those notes and it sounds amazing. I think this song was a very nice shift in what we usually hear with FNAF songs, which is always welcome to see. I really hope Docko and Houston experiment a bit more with other types of songs. Because, and just being honest, all FNAF songs kind of have the same premise, kind of have that same beat and feel to them, but Lonely Freddy sticks out very, very well, because it's so different from what we're used to, and I applaud them for that. That's crazy.  So a very nice song, a very sweet song, very enjoyable.  And again, the animation, especially on Lonely Freddy himself, insane. Very, very well done. So that was Docko and Houston's Lonely Freddy song. A very welcome change, and I'm very intrigued to see what they do next. The next song is out of stock and Docko did do a preview of it, but he also did say that him and Houston are kind of re-walking the song, which, you know, I'm fine with waiting. I hope it's a beep. I hope it's a beep. I hope it's a bop. That's what I meant to say. Yeah, I'm looking forward to what else they have up their sleeves. I know we have a Oogie Boogie song coming in December and then Dark's Desire 2 coming out in, I believe, October, kind of near Halloween. So we got that to look forward to. Thank you guys so much for checking out the video. Tell me what do you guys think of the song in the comments down below. Make sure to subscribe, hit the like button, and I'll catch you all on the flip side. Goodbye.


Testing testing testing testing All right, it's three o'clock so I'm gonna start it. This is rust system programming for web developers Before we start out, I do have a confession to make.  I've been doing it for 10 years, but I love rust I fell in love with this language and so I work at Norsham rack comm slash hope look during the day writing PHP and managing and I write rust sort of on the side So before we get into rust itself, let's actually talk about what system programming is There's no definition of everyone's in a grana about what system programming is and those of us in the rest community seem to have Coal us around this definition of system programming is when it matters So I'll give you an example of when it doesn't matter I'll pick on Ruby this time Ruby is slow, but it doesn't matter because the database is a bottleneck So when you're writing Ruby code, we're not calling that systems programming Right because it doesn't actually matter if Ruby's a little slower Than where you're adding it in C because you're bottlenecks the database, right?  You're gonna find great control over your memory management So we see that a lot in C or C++ and you're gonna have zero cost Abstractions so that basically means is you're writing code that's sort of against the metal or against the hardware, right? You could be flipping registers on and off if you want to you can Represent a data structure in the exact size of memory that you specified You can make entire programs sort of allocate memory on boot and then allocate nothing afterwards running just on the stack And then free up at the end. So you have a lot of control So that is systems programming and let's talk about why I think rust is a great systems programming language And why I think web developers should take a look at it Start with some history. So rust is a language that's sort of been developed by Mozilla It was developed with the primary use case in mind see a Mozilla runs as you all know the Firefox web browser and Since the web is such a popular place nowadays There's lots of events like Pone to own or a bunch of security researchers or hackers will get together and they will Present their exploits and they do this with Firefox and Chrome and every single browser out there and Mozilla Sort of knows this pattern where all the exploits were basically coming Centered on this sort of one vulnerability, which is a data race And now it sort of happened when they would sort of have all these sort of threads running You know, they write C++ all this threaded programming going on to make Firefox fast even though Chrome faster, but they got all these threads going on and There'd be sort of some some mistake that someone would make with the way the threads are working and sort of sharing memory that would cause a data race and hackers would take advantage of that and make the web browser do things like a remote command exploit or They would allow it to make it do something like going to like a web page or fetching a resource that it shouldn't And this was driving Mozilla crazy. They wanted to fix this So Russ primary motivation is to sort of fix this problem that Firefox is having about sort of not having some sort of safety Checks around this because they're programming even for the most experienced developers super hard So what they did is they developed the working and developing now a web browser engine called servo Which is sort of a replacement to gecko So if you don't know Firefox uses the gecko rendering engine to actually render out the HTML and the CSS On your web page, so they're not really building a new browser But sort of building a new engine we actually already see elements of rust and Servo kind of being feathered into the existing Firefox browser So before we get too far to we're talking talking about your web developers, hopefully is anyone here actually written a rust program before So a fair amount of rush stations in the room. That's great Welcome, but if you're a developer, you might be asking yourself this question Is rust good for web development and the rest community sort of has this pension for making these websites called like are we blank yet? comm and Are we get comm you can actually go this next talk about? writing a web browser Or say web service in rust And you can do this, but I think it's too early to tell if web of rust is me good for web development Rust is primarily assistance programming language.  Normally isn't worth it, right? web request we hope are under like 200 milliseconds We're trying for expressiveness in our web code. We're using GC to kind of save ourselves our memory management a lot of times So it's just really not worth it to sort of do that Also, we don't really need fine-grained controller for memory because again We're only 200 milliseconds is our span. There's some memory leak or somebody overhead the request is gonna be finished up quickly Anyways, and we'll start over again Also, rust does is a is a compiled language. So there's a compilation step So we're not really gonna focus on rust for web development. I'm gonna sort of slant this over to Why we have developers to sort of look at actually getting involved in a systems programming language Yep, so rust possible developer. I contend is gonna be a can be a systems programmer, right? So let's talk about this. I think I did actually skip a slide So rust sort of provides these three constraints, right memory safety without garbage collection concurrency without data races and Abstraction the overhead which we talked about is sort of what makes up system programming and we're gonna sort of go through these And how they can be applied to web developers So I sort of have this this basic theory, right any time a new programming language comes out These bunch of people will get on the internet and they'll say something like oh this language is gonna replace all the use cases for this other language Right, we saw that with rust too rust was sort of coming out. It was eight years in the making. It's at 1.6 now People were sort of discussing a lot. Oh, do you think rust is gonna replace your C++? I don't think that's really actually the case if you're writing C++ right now You're probably pretty comfortable in a language that you've been writing for years and years and years and you might switch But a lot of people like they have no reason to switch they're working a day job using C++ and they sort of invested all this time energy and getting Familiar with that and they can sort of you know work through that. I actually think that Rust won't be a C++ killer and I think Instead web developers are sort of the largest group out there right now of people in like the software developing community Lots of new people coming in and I actually think rust is sort of well-positioned given some of its features to actually be attractive To developers and actually grow the overall pie So there's really not a focus on actually cannibalizing that existing blue graph blue pie chart area of C and C++ developers, but I'm actually arguing like I think rust actually can put a nice slice of Of new systems programmers into the community, which I think is sorely needed I think there's some historical context to this, right? I just didn't like make this up out of thin air. We've sort of seen this so Does anyone sort of was programming when Rails came out ever the same thing happening where there was a bunch of Debate going on in the web development community talking about like would rails would Ruby on rails sort of you know Unseat PHP is the dominant web language would it sort of take over and you see these You know blog posts flying back and forth rails is faster and PHP is faster and sort of it's never ending right and their benchmarks benchmark slide But what no one sort of understood at the time is like cloud computing is in its infancy, right? Like easy to starting to sort of get more popular. There's other competitors out there We're like we're virtualizing so many things you have a whole generation of ops people that aren't even they don't know How to work in the cloud right there used to like procuring some hardware like setting them up You know with some custom batch script, maybe the using CF engine And then like that things is gonna run and we're never we're gonna pretend like it never like shuts off And if God forbid it dies, then you know, there'll be some horos going on and what happened with the Ruby community, right? Like they're wanting to rails is new people are coming in they want to get this stuff in the cloud And there's no tools for that and then the Ruby community finds out is Ruby's a great DSL And they start writing the tools themselves and all of a sudden you get things like cap astronomy for deployments You get puppet and chef for as a much better replacement to CF engine for configuring servers You have multiple sort of ways of running multiple Ruby versions and development and even God forbid production if you wanted to You have awesome sort of developer tools like vagrant, which is a Ruby script around virtual box It makes life much easier for us and things like sense you which is a Ruby replacement For Nagios so all these great. So Ruby didn't create the DevOps movement But certainly what they were doing they found that Ruby wasn't replacing PHP It just actually created this entire generation of DevOps people that have built a bunch of tools that basically everyone in web development community uses or has been influenced by So I was that sort of happened. We kind of see it actually going on now, right? You take a UI developer slap some note on almost and you got a full stack full stack developer like but why is this right? So I was a PHP developer when node came out and I remember looking at node going why Why would you why would anyone want to do this and a bunch of other people who were writing Python or Ruby said the same thing? But what's going on here and note is a new technology, right? Like nothing that node sort of brings to the tables brand new you've been able to render JavaScript on the server For years using Rhino. We've been able to do a sync IO Using LibEv I think was that what it was before LibEv was created and used in Node So there's no there's no new technology here. It's been around at least a decade Why all of a sudden like is this such a powerful movement like what's what's going on here? And you just sort of think about like what's eating the desktop, right? And if you're a UI developer your requirements being given to your like hey make the web feel like it's native What fast and everything dynamic? I don't want to reload the web page Just make everything like single-page apps age absolute everything. So these UI developers are writing HTML and CSS and JavaScript They're going to the Ruby person and they're saying hey I need you to give me like a lot of this like event driven sort of interaction You do a lot of this stuff for me, and they're going like what are you talking about? I know like rest That's all I do and they're like no I want web sockets. I want you know all kinds of like you know nice interactions and There's this there's this friction, right?  Here you go. So now all of a sudden you have a full stack developer. It's happening right now And for a long time the server side people just didn't get it You saw blog posts like no JS is a cancer people putting up blog posts like hey Fibonacci runs really slow and node and as we all know now it's more of a mature ecosystem like it's really powerful It's really good it complements a lot of what people are doing out there And it didn't so no one lost their jobs doing PHP or Ruby or Python development But what you have is a whole generation of people who are only working in the browser now working on the server side as well So I think the same thing is gonna happen with trust right you're gonna actually have a week and have web developers And you're gonna sort of convert them into systems programmers And that's not to say you're gonna stop being a web developer You might actually just do both like you're just gonna sort of you know let this sort of enhance your tool set And so it but and why do I think this is needed so as we all know like ten years ago We were building monolithic applications right One repository a web server Maybe your runtime behind that and if you want to scale that out all you kept doing was horizontally scaling right spinning up More VMs are procuring more hardware and that's unless you like the point one percent of the industry That's basically how you scale Go more databases behind and read clusters right now even sort of the average sort of Engineering shop has micro services and all these different parts of their application And if you start going through like some of like the concrete examples of each of these you're gonna find out like None of them were actually written in the languages web developers know Right yet. We're highly reliant on them. So if we're talking about application caching like memcash or redis both written in C HTTP caching layers varnishing squid Job cues I think rescue might be like the one example here if you're in the Ruby community We have like a Ruby sort of implementation of a good job cue that you can use if you're in Python or PHP like no Using something using like gearmen or rabbit Relational SQL databases these are all written in CRC plus plus Search databases the next other exception here. Those are written in Java Though any ops person hates this because you know when you're running high workloads and the GC pauses on you at your most critical time You're getting really mad and see fight with it non-stop and every ops person wishes that these are written in CRC plus plus Load balancers and VM in containers like we're all like VM in dock rising everything under the Sun right now, right again All written in a non web language. So we're highly dependent on this entire ecosystem of Software that web developers have basically very little access to And what you basically has of this massive knowledge gap, right? Well, it makes it worse that all this stuff is open source So there's really no one getting paid to do this stuff Which means you have very very few people actually working on this this is open source software they actually have the know-how because it's CRC plus plus and This is bad for a few reasons one like we've seen burnout in the community Also, we've seen that a lot of these maintainers don't have time for things like you know important ancillary tasks like Documentation or putting out proper releases and things like that Also hinders the state of the art when you don't have people sort of like fresh people getting into a certain area Sort of a couple winners or merge and then things sort of stagnate, right? We saw this with the web browser for a while where the where web developers weren't actually involved in the web standards You had a bunch of C and C plus plus people that were developing browsers Sort of you know figuring out how API's and the web worked and when they would come out all the Like what are you doing like that makes that does not matter use case at all only recently do people In the web community have they started joining TC 39 we've been getting things like ES6 and ES7 like that wasn't an accident folks Like it really took web developers getting involved. I think Likewise, we're missing core use cases in the web community because we're not getting involved to solve Parts of our web stack for ourselves because we know best And I and there's a clear example as I write PHP during the day all the time PDO is the then sort of the Database adapter abstraction in PHP means PHP data objects. The person who wrote that was is a C programmer he doesn't write PHP and The way he wrote it in the constructor of PDO when you do new PDO with people normally do in the bootstrap That actually makes the network connection to the database like no developer web developer wants to make a Connection to the database in the boot ship of their code unless they're explicitly saying it and you have to like kind of work Around this as a php develop like everyone has to do it's crazy, right? And it's because I think you know Wes wrote a great library, but he missed a core use case because he wasn't actually involved in the php community So I'll go ahead. I'm sorry. Yeah, I think The For the video saying I'm overselling it sort of laying out sort of like the background of why I think web developers are getting involved in Russ now and We're gonna go through certainly a lot of code examples, but I thought sort of the history was important to sort of present So some barriers entry for web developers to get involved in systems programming, right? Why haven't people and this is why I think I want to set this up like Russ is fundamentally different here, right? Web developers aren't getting involved in C and C++ because it's unapproachable in my definition, right? There's a problem with memory management when you can sort of compile your C program and it compiles fine And then you put it into production and all of a sudden it's seg faults on you at the most critical time Like you're not going back like that's a super painful experience And so if you're a web developer trying to get something done and try to get this critical task out But that's not making you look good C or C++ sort of provide that foot gun for you And you can't sort of rely on GC if you're doing systems level stuff as we discussed and I think a lot of web developers Don't want to write C or C++ because it's not an expressive language, right? When we write Ruby, we like how expressive it is when we write Python We like not having to do semi-colons and we shouldn't have to necessarily give all that up We want to write systems programming And a lot of times we don't need types and we've kind of going to custom not having types So Russ can kind of solve a bunch of that stuff, right? So these are the three tenets of rust and we're going to go through and talk about how they allow you to do memory safety Give you fine-grained control, which is your cake and sort of not let you suck fault eat it too We're going to show I'm not getting too much into concurrency because it's hard to show in examples But we will get into a lot of abstraction without overhead but I do want to make sure everyone understands like I think too is super important here too because as we know right now we're taking a Single piece of hardware like a server and we're breaking that down into virtual machines and Docker containers I think at some point pretty soon here in the future. We're going to see a lot more use case or something like that patching That's what we're taking actually Multiple machines trying to make them work in concert together and right now trying to do that if you have Architecture that's horizontally scaling you sort of know that that actually is a lot of time and effort to make sure those things are Coordinated correctly so having concurrency without data races is super important. I think for a sort of the future where a lot of this system stuff's going All right, so let's get into some of code examples Rust right out the gate has basically this concept of ownership which allows us to sort of have Memory safety without garbage collection. We're going to go into some examples of how ownership works So I'm going to start walking you through rust syntax with the examples if any of the syntax doesn't make sense You know, let me know But in this example we're defining a function take that has a single variable V of type vector of sing of signed 32 bit integers And then below that function. We're going to actually define a variable V That is a vector of 1 2 and 3 we'll pass that variable V into our take function And then we're going to print out below that the first element of V and any other language that we've probably been exposed to This is perfectly fine perfectly sane and perfectly normal. It'll compile it'll work. It'll run in rust This is an error And all it comes down to ownership Right. We are actually passed our V into the function take and once we did that We have given up control in that scope of using that value V again. I'll show you the code again So line three once we pass V into take We are no longer allowed below to use V or access a D anymore and this fundamentally I think there's way there's references and other stuff that rust introduces here But this fundamentally is how rust gives you memory safety Without sort of the garbage collection piece here It basically ensures at compile time that you're not doing anything that would basically cause problems, right? And this is really nice because it solves a whole class of problems that C or C++ don't solve for you You don't have segmentation faults anymore Because you're not basically allowed to sort of use after free essentially, right or even use before you've allocated it The compiler is sort of using this rule called like the barb-checker It's using this barb-checker is going through and basically making sure at compile time You're not doing anything that would basically blow up your program at runtime And you also don't have memory leaks anymore because rust is sort of handling that the freeing app after it's allocating It's also handling when it's supposed to free. She got to worry about this whole notion of I need to have Functions that are dedicated allocating memory and then making sure I'm only freeing that memory and then nothing else is sort of accessing it, right? And if you've written C C++ before you know, this is sort of a chore to do and rust does it for you for free The problem is when you sort of start out with rust you're going to start fighting the program because As you saw like that was a perfectly valid program that we wrote and we all know that like that's how we write code And rust doesn't let you do that and so that you get nearest when people start writing rust They normally start fighting the barb-checker and I'm like, no, that's perfectly that's perfectly normal I do that in like this other language. Why won't you let me do that and really what's going on here is the the sort of The barb-checker isn't doing anything actually you shouldn't be doing if you're actually like a grizzled veteran C++ developer You basically have been turned like internalized like these conventions of the barb-checker and what you just sort of know Like it's like tribal knowledge to you You go through you read like some like the best C++ development books will actually like outline these steps Like makes you do all these things and what rust did is basically codified back into a compiler So what rust is, you know, when you're fighting the barb-checker Kind of take heart and that you're kind of making an investment and that the compiler is literally teaching you Painfully at times because it doesn't care how frustrated you are and it doesn't actually go on vacation But it's teaching you to become a systems programmer And you could actually take those same rules and apply it to other systems languages and be just as successful One thing actually like about this too is you could contribute back with confidence, right? How many people have sort of wanted to put a patch into a large program either where they work or even an open source and Kind of felt a little uncomfortable about actually pushing that pull request button, right?  And the great thing about the barb-checker even though you're gonna fight it at first You're gonna get to the point where like when that program compiles you pretty much know that is it's gonna work And if it does blow up, it's not gonna be for some obvious thing. It's gonna be for something kind of crazy And so like I myself have Contributed to rust core and I'm not like that good of a programmer and but once the thing compiled I just felt like I can push I can push the button here I can actually send this patch over the wire because like the compiler told me I'm a good systems programmer And for this particular piece of code Cool so great so now we've you know, this is why Russ is so compelling in terms of Writing save code, but you know, I did talk about like we don't want to give up some of those aspects of scripting languages that we like Right, so let's get into some of these things that Russ does that we don't look like we're actually writing so much sort of C or C++ code so Russ spends a lot of time on ergonomics and We do think writing the code should be as enjoyable as writing it in a systems like scripted language And we want the compiler of use the compiler to figure out all this borrow-checking stuff Right all this ownership stuff, and we also use the compiler to figure out all this sort of boilerplate stuff that you Have might do in other languages that have strong types and we sort of meant let the compiler for it Like you know, I can't get an example to come on a closed out But here's like in Java right get to define the types on both sides of the assignment It's like why I just defined it on one side just figured out on the other side and what we end up doing right is instead We we produce IDEs that basically fill in all the boilerplate for us, right? And instead of using IDEs Russ, so let's just stick into the compiler So here's an example simple example. We're gonna find some variable foo. That's gonna be a typed Sign 32 bit integer and we're gonna sign it to the variable five and as humans We can all reason about very quickly like that's a number. I don't need to specify the type So neither does the compiler and this looks like a lot of languages that are like scripting languages, right? But foo equals five no type necessary That's great for like type Like assigning like variables of types. We also can go one step further the compiler can even figure out In certain cases how to even default the return type So here we get a little more complex. This is how Russ defines a closure so we're gonna find some variable f and it's going to Define a lambda function that takes in a single variable x of type sign 32 bit integer And it's gonna return a sign 32 bit integer and it's gonna return x and this is an example of the identity function If anyone's curious and this is how you write a closure in rust or a lambda function in rust It's pretty pretty terse. We can even get better That is how you can write that same function in rust and again that looks a lot like a scripting language So you can go all through a lot of your rust code and not actually worry about specifying the type and That's nice because Yeah So I'm gonna say that the reaction by actually writing it So not only is it nice not have to write the type in certain cases. This is actually more expressive even to To your code because you can use the same function to actually Allow multiple types come through and the compiler will know that so it's even actually better like this is encouraged, right? Late new as programmers were sort of taught like laziness is a good thing and here it's showing up in the positive And we're going to go a little more complicated example These apostrophe a things are called lifetimes. And so what we're doing here is we're defining a function That's very similar to our identity function called silly And I'm introducing this concept. I'm introducing a lot of concepts here, but ampersand means reference And that lowercase str is a a string type one of the string types in rust So we're passing in some Variable s of type string and pass as a reference and pass in that reference back out And we see like these apostrophe a's All of rust's functions require you to sort of define these things called lifetimes And that's how it actually figures out how long things like references should live for it's all really complicated to be like, you know Some programming language theorists actually figure out a lot of times when certain lifetimes can be used But the great thing about rust again, we're using the compiler like 90% of your code Does not need the lifetimes at all the the compiler infers it This is actually really nice because we get all the power of lifetimes without having to worry about it So if you're a new developer and you're trying to do something in rust You don't want to have to start thinking about lifetime to try to just get something done, right? And so the default here is lifetimes lifetimes are there under the hood But they're just sort of like inferred for you and when you want to actually turn on like the advanced switch Like you can switch that advanced switch on and start telling rust No, no, I know exactly what i'm doing here are my lifetimes and be really explicit about what you want to do So you get all the control with sort of none of the penalty All right at this point we sort of kind of kept it pretty introductory and I've been introducing a lot of things that are probably Pretty basic we're going to sort of step up a notch here to a little more theoretical stuff that's going on Anyone has any questions? Please stop me and ask So um optional correctness Yes, go ahead So the question is is the bar check a reference counter? No, it's not the bar checker is a program that That there's by default. There's no sort of reference counting going on We're we're literally at the middle level where like c is It's it's just it's it's there's a couple phases in the rust compiler This is the first phase that it goes through and just sort of make sure the semantics of your of your code Aren't violating sort of any of these constraints, but so it's not a runtime thing. It's done at compilation time lifetimes. Yeah, I think about lifetimes as basically a um It's less of a scope. It's almost like Typifying sort of how long Reference to variables should live Lifetimes are one of those things I introduced it. It's going to come up if you're getting into rust You don't need to actually worry about them hardly at all But you kind of want to know what they are in case something in case you run into something when you're using a reference I would say most people can I've written rust and they'll go months without ever needing to put one lifetime in place So they're there be aware of them. Don't be scared of them All right optional correctness One of the things I love about rust is it sort of takes this nice balance of theory And applying that theory to actually real world problems And as we know the real world is not always sort of on our terms And so, um, you know, I like like a language like Haskell. It's great But you may have to jump through a lot of hoops sometimes to make your Programs work and I think rush tracks is really nice balance. I think we can sort of Great example this balance is in rust. You can do really return types, right? So we've all seen this type of code. We're going to let r equal the value of some function Return type of term value of some function if r is an error, we're going to return early return false And then we'll go down our happy path code, right? We've all write that when we write like our our normal code And we write that in rust too But rust also has this monadic type, right? We're going full burrito now This monadic type option that can wrap a type t So any type t it can wrap this and if you're not familiar with option It's like the either type in Haskell Option can basically say look if there's something here of type t or there's nothing here, right? So it kind of maintains these two states and if you're going to go like to programming language theory sort of side of things This is a monadic type and monadic types are not allowed to return early Rust is like whatever you can return early. So what we have here is an example Let variable flu equals some string bar and we're going to use the find function on foo to see to find the character b Right and this match statement in rust. It's kind of like a switch statement, right? But it makes sure like you sort of cover all the different use cases So as I said before option is either there's something there or there's nothing there So if there's something there some character see there Then we'll just return c back to our variable. So c, you know, is the is where that position is Um, and we're good And that's what this code is going to do, right? We can have a different example where our string is no And b's not there and we're going to go into the this other branch of code This other harm of our match statement where it's not and we're going to call this this Macro panic which basically means like fail air Bail out of your code stop running the code. It basically return early type So, you know, when people sort of uh, if you're a programming language theorist, you see option like I love monads But rust is like look you can return early too. So you kind of get all the power of monads Like sort of all this simplicity of sort of returning early Which is just easier, right? You don't have to like sort of contorting your code to say like, okay I get only one return type at the very bottom of my function scope You're trying to figure out how you can break your functions even smaller functions to deal with sort of the different um If else, you know statements that need to happen Um, it really makes things much more approachable And this this pattern right here is so common in rust that they actually made it even easier to do and they have this method called unwrap So this is the same thing as before That basically unwrap will say look it if you found what you were finding I'm just going to return it to you and if you didn't I'm just going to blow up the code And I feel like man, why would rust put that in there? I thought you said this was supposed to be like memory safety and like Really good systems programming stuff. Well, it's true But if you're starting out in rust or even starting out trying to solve a problem You don't want to you're not worrying about correctness, right? You're trying to hack your way from like start to finish and get something compiled and something generally working to see What you're at, right? We don't normally explore new spaces by sort of by doing tdd first, right? Tdds after you've already sort of mastered your ruby or your php or python Tdds when you're sort of just trying to you know, you're on rails if you're starting out rust or sort of exploring some unknown problem Where you're trying to figure out like some weird protocol and you're twiddling bits You don't want to begin with tdd, right? No, you don't want to be doing the really correctness either you want to turn that off and so you can use unwrap So a lot of time that people do is they'll write their code and they'll just do their first pass and everything goes be unwrap unwrap unwrap It's fine if it blows up. It's just it's not production ready yet That's okay.  You can do all these different things. So it's really nice Again a pragmatic approach And really I think it goes down to rust sort of says like the programmer knows best Like we're gonna sort of put all these defaults in place and we're gonna sort of set this really nice This is programming language up But the programmer knows best and we'll sort of allow them to sort of override things when they want to So much to the point that rust also has this notion of unsafe Where I sort of told you before you had to satisfy the baro checker if you wrap coded unsafe Baro checker says I trust you So here's an example where we're actually creating the sparkle heart emoji out of a vector of Bites and we're saying like look at rust trust us. These are valid utfa characters If they're not Then that's on us and what this is sort of nice is like it again It allows us if we're trying to really take A theory and apply it to the real world. Sometimes the real world is not in our terms. We need to do something crazy, right? Um, in this case, it's sort of we're sort of demarcating like I need you to trust me right here rust and also to all the other developers out there like hey I need you to trust me here rust is it doesn't have my back here. I'm saying I got this So let's talk some about zero cost abstractions what I sometimes call mullet driven development Uh, you're gonna get all the sort of the expressiveness or actually all of it a lot of the expressiveness of ruby So you get sort of ruby in the front when you're writing your code But you don't take any of the performance costs really get like c in the back, right? Um, this is great. So let's go through some examples here Right here. We are defining some variable n and then taking a range of numbers one to ten We're first mapping them. So we're multiplying all those numbers by two then calling filter on them So any number greater than five we're dropping and then we're adding those all up with our fold Function here with our with an accumulator This looks very similar to something like right like in python or ruby, right? And this is like if you're like, you know, we'll cutting edge ruby is at this point like you're like no for loops ever I map everything. It's great. Um, you can sort of do the same thing in rust But if we wrote this in ruby, right like first we're going to um, basically Loop over every single one of those numbers one to ten once from app And then we're going to loop over the numbers again for filter And then we're going to loop over the numbers again for fold And that's going to be basically three n times Now if you write ruby again, it doesn't matter because that's not what you're trying You're you're you want expressiveness. You're not trying to optimize your code for performance You want expressiveness maintainability readability and we take that hit.  So it actually this is dollar rust code what rust is going to do under the hood Is take map filter and fold instead of doing those three iterations It's actually you know, create like a single loop and actually do all that work in a single path through of 10 iterations It'll actually inline map filter and fold and sort of do that in sort of one one shot And you know, so you don't need to worry about it Like if you want to write your code expressive and make it really clear what's going on You don't have to go back later when you when when you want to optimize it and sort of make it almost unreadable Has anyone ever looked at the open SSL code layers before? Like you wonder why there are so many bugs in that thing, right? They're trying to make this thing fast and when they do that it becomes almost unintelligible What's going on here? We can make it really clear what's going on yet still get all the performance out of it Could you add more? The question is can you add sort of methods like this as a user of the language? So the nice thing about rust is rust is written in rust and these are just iterators So you can write your own iterator methods and and sort of do this yourself and you and people do this all the time Another question Yeah, sure The question was why does filter take a reference instead of the actual type? The reason why filter takes a reference is it doesn't actually need to own the variable to fix it's just basically Um Needs to sort of use the variable to check something real quick Unlike map map might actually mutate the variable filter is just sort of peering into it So you don't actually take the variable. You just take a reference to the variable And that's common like in the generic filter method, right? So these are all like immutable things So you can make map take a reference if you really wanted to other questions And then we can even go one step further Where rust really does have first class functions Like a JavaScript Um type language, right? I wrote some code. I created a simple Ripple read evaluate print loop for rust and this is what my main function look like Again systems language over our read evaluate and print are all functions And again the compiler using LLVM compiles is down and I'm we're taking no performance hit And we're getting sort of all the the monadic stuff going on here with the admins We have all the expressiveness like it's very easy to see what I'm doing here And all the speed of c Let's go one step further with generics If I define a function here first And if you're familiar with like java or anything like that We're defining a generic type a and a generic type e And creating a tuple out of those values And we're basically just saying like it's going to return that type a in the body of our function We're saying for that tuple just return the first one. So that's what the function is doing, right? Very simple Most languages have to do this at runtime, right? Like if you do this in java um Java is actually figuring out at runtime like how to actually like Figure out all the typing stuff and and you can run into some problems there where it can actually not figure it out um So for rust we can do the same thing like uh, you can't with any other generics We pass in integers. You can pass some strings um And uh, and you know, even when we do this is something like ruby or php or python It's doing this at runtime. We just never see it. It's a hidden cost, right? Actually, what rust does is it has this concept of monomorphization Long word don't have to remember it But essentially what this does is the compiler creates a specialized function at compile time for First sort of each type, right? So if we're passing in uh, um If we're passing in an integer The compiler goes oh, I see you're passing integers in your program I'm going to go and create a specialized function for integers for passing in a string It's like I could see you're passing in strings as well. I'm going to create a specialized function for strings I can look basically like this like you could do this yourself too, right? You can write specialized functions rust does this for you for free So you have to act you can write really generic code We saw with our closure example earlier and under the hood It's creating these specialized functions for you that you don't have to manage It's just like I got this for you So again, all the expressiveness of sort of a higher order language with none of the sort of the performance cost Sort of question Uh, and this the question was could you have a string and a numeric? I am defining two discrete generic types. So you could Um, I didn't show that example, but yes, you could kind of come do any sort of generic stuff typing that you want Great, and then let's move into, um Another topic here. So systems programming We might think if you want to write become a systems program or write system assistance program You got to write the entire thing In sort of that language, right? It's all have to be in c or all rust or all c plus plus Actually, I would argue systems programming doesn't sort of the definition doesn't actually require that. Um What we can actually do still is write the bulk of our program in something like ruby And then once like we're done writing that program we can actually go back things like is there any like really Like slow bottlenecks that are not IO bound vcpul bottlenecks and if there are we can actually drop rust in Um to actually solve that problem I actually did this there's a library out there called selecta Um, which was written by gary Bernhardt, which is really nice sort of little command line utility That allows you to quickly search your file system for things It's really nicely written and had like a full tty and all this support But there was this one hotspot in the code where there's this really efficient search algorithm But because it was ruby, it just could never run fast and it goes always like the biggest bottleneck in the code I actually just took that library rewrote the search algorithm in rust And um put it back in uh compiled it into the overall program in ruby So ruby could just call my rust code and we can do this because um rust treats See as sort of the common language across the entire ecosystem, which is basically true, right? And rust interrupts the c really well I'm not showing an example here because it's it's it's a it's a fair amount of code to um get it going but There are a lot of examples of uh this on the web On my blog post I have one for php again. I've written one for ruby. It's fairly approachable There's some obviously there's like some boilerplate work to sort of tie into those c um Interfaces that are sort of defined But rust makes again makes it pretty easy and because you have all that fine-grained control rust Rust isn't like a gc language, right? If you try to do this as something like go which goes a great language, but go as a gc in it And if you try to match goes gc up to ruby's gc, what do you think is going to happen? like not good things um Because rust doesn't have a gc just like c or c plus plus um you can easily tie into this even note so what recently came out to was an example from um someone uh at the Remember his name now At mazill actually put a whole block because about how you could actually tie Rust into the no j s runtime, which is written in c plus plus a little bit harder than c Let's see here. So I went over a lot of concepts It's really hard to sort of go through some of the code examples here But uh my these there's a lot of sort of ways you can sort of start digging into rust Oh, there's actually a rust book out yet, but the documentation on the website Uh is great Steve Plabnik has done a great job. He's actually put up mazill and does that full time But actually even better we learn rust is to come to the rust of los angeles meetup I actually run that meetup And we do things like last month We took there's a new program out there called a stock fighter anyone's heard of stock fighter before And we it's basically A game where you write an automated stock trading Um Program and it's it's pretty real not a hundred percent real. It's pretty real and uh, Believe it or not now I've written a rust sdk for it. So we're writing a rust sdk And really I think the hardest thing about you know with any of this stuff is getting started, right? Rust lowers that barrier to entry to get started a lot But there's always sort of something that doesn't make sense and so if you're with a bunch of other people Those questions get answered really quickly and you actually feel like you're making a lot of progress There's the website on there And again reach out to me if you have any questions That link at the bottom is a link to all my blog posts on rusts and there's actually a number of them on Strings, so if you do start writing rust and strings are frustrating you Go ahead and check those out to make things a lot more clear But feel free to hit me up on twitter or you'd have or anything if you have questions as well And with that I'll open the floor Yeah, you can there's actually the question was can can you generate a rust program for something like Arduino? Rust recently in 1.6 was just came out Actually a stable support for not including even the standard library of rust only just like the bare of the core Components which allows you to compile it for things like the Raspberry Pi or Arduino And basically the footprints very light you get you get just the bare bones and then It is I realize that um you still can do for the Arduino you Rust the rust compiler has compiler targets And you have fine great control over the different compiler flags that you can send and make and you can sort of compile it Anything you compile uh c2 The the question was how small can the is the rust binary? Yeah, so rust hello world is a little bit larger than you might think Because again, it's doing a lot of that sort of specialization under the hood Again, if you need to optimize something you can do it unsafe. I don't remember off the top of my head But I know it's it's it's fairly it's it's a fairly large hello world. They have not tried to optimize for the hello world example I know um some people have been interested in that but it's kind of a red herring I think once you get into something that's beyond just a simple program It sort of gets amortized out and and you're basically um sort of on par with c or c++ Don't quote me on that. You you could certainly ask on the rust users um forum And they would be able to give you some direct examples. I think there's been some talk about that So um, I'm not into that space as much so I can't I'm sorry. I can't answer like definitively Yeah, but certainly it's it's a of a lot of interest to the rust community embedded programming stuff like that other questions Joel and then There is a rust um libraries or user libraries and rust are called crates There is a rust crate that's starting to replace parts of open ssl I think you know rust is 36 weeks stable They went through eight years of basically um prototyping to solve that main core use case that of servo So we've been 36 weeks in like in like production mode like a 1.0 release and we're 1.6 now And I think really the community is sort of looking at things that form like that a 10 year frame of reference So I think we'll see more adoption of those things as they come But um sort of things are kind of going slow as we're sort of figuring out things like Even things like higher kind of types I think as we sort of figure out more and more things within the community You can see more adoption and see things like I can open ssl solve port to rust or other things like that I myself Do a lot of work with a library called mia, which is a replacement for Live UV so it uses things like equal or kq if you're on vSD But it's a complete rust replacement for live UV that is and then I think dropbox just Put out that's what they use to sort of create their Hard drive mesh and to figure out a load balance all those different files across your system So it's coming and some people are really interested in doing that because it's just it's nice to write it So, yeah Your question So the question was can we talk about concurrency control and rust? Yeah, it's I would have to dedicate like 10 slides. I think sort of to walk through Just how that sort of works under the hood. Um, there are some examples up, but essentially rust is using the borrower checker and You can sort of reason about how you're allowing Threaded computing to share memory via the borrower checker And so it does that all at compile time. So it's really it's using that those same semantics It's sort of enforced that you're not going to step on a piece of memory So once one thread takes ownership for piece of data the other thread just can't you don't need semaphores or new texts at that point, right? There are and then you can actually use a lot of other semantics that like when things get freed up Or out of scope to pass back ownership upstream to a different thread So like there's a really good way you can like do that with channels, for example, it makes really easy So the question was is that better than go so go? You just focus more like on their like go routines, right? And they do have channels and stuff. Um, I believe the last time I checked the go Go Routines actually leak a little bit of memory in order to do the a lot of their safety guarantees So again goes goes a great language. I think it's you know, it has a lot of use cases I think to like write to like replace A lot of java stuff for like web services. It's like kind of lighter weight than java I think that's where it really shines and again, you don't really care about if it's a little bit of leakage there, right? but um There are coroutines and rust you could do the same thing, but um, they just sort of have different strategies again Go has the garbage collector other questions Here and then we'll go back to you What is the next ruster? Yes, the question is when is the next rust meetup and where do we meet the next all the meetings are usually in the middle of the month so um It's whatever that Wednesday in the middle of the month is and we meet and we meet in The notion rack Slash hope look production studios in culver city And if you go the website has like a Huge thing of direction so you can get there. Yeah, check out the website has all that information. Hope to see you there question Yeah, so competition is good. Um, I actually don't think it's really gonna impede it too much You know, we've even seen like in c++ a lot of stuff that we've been doing in rust The c++ community has been trying to do To like take on as well. There's actually now some sort of certain pointer types that sort of have some kind of Ownership and properties that rust has been sort of messing around, right? If they're already like things like own pointers and c++, I think um Swift is going to sort of make it more again make things more accessible. You're going to get a lot of people who were writing iOS apps Trying to write actual like, you know server side stuff like in the usx ecosystem So I think actually it might only speed up adoption of something like rust They have a lot of similarities, but they also have a number of differences too Um that the swift community said like we're not we're not trying to compete at that level that or that sort of some of that Compete some of the areas where rust is trying to compete another question so the question is does if The question is if the difficulty of functional language semantics would be a blocker for the adoption of rust So rust actually isn't rust actually is an expressive language not a functional language So it actually can do a lot of functional things Um that you find other languages But every single thing that you do in rust is an expression I mean by that is you can actually assign a variable to the result of an if statement Um Which is actually after a while quite natural So you don't you can write your code in rust and the most basic imperative form that possible Just straight like like almost in like in that classic c stop, right? Which is a bunch of functions and that you just sort of cobble all together make a program out of it So again a lot of the stuff that we talked about is opt in you you don't have to take advantage of like map and filter And fold if you don't want to You can actually just write just normal functions and it'll work just just the same So I actually don't think that's too big of a deal. I think it's really more of an upsell that it can do those things cleaning most people Sort of want sort of a higher order feel to the languages they're working in now Question the question was does rust have exception handling? So rust does not have exceptions It does have a macro called try Which at first glance might look like like though and I like deal with exceptions That's just bubbling up things like options or result types But the the language designers make and made an explicit decision not to sort of add exceptions into the language Panic and then though the things look like exceptions as well like they'll sort of quickly abort the program But yeah, I don't think there's any plans for exceptions in the language as well That's sort of a highly debated topic, but That was the decision Any other questions? All right. Well, thank you so much for listening to talk. I hope to see you at the meetup Like At Oh Oh


Qs. Let's start from the Qs. So Qs are pipes. In fact, there are pipes to transfer the data between tasks in free R2S, in general. The transfer of the data can be done as well from interrupt to the Q. But in this case, please remember that the interrupt, which would operate on the Q, should have the correct priority number, not higher than specified as a max syscall within free R2S config.h file. By default, the Q is behaving as a FIFO, so first in, first out, and can be redefined to perform as last in, first out, a structure by using eqxq sent to front function. The problem is that this functionality is not available within CMC's R2S API. So in case you would need it within your implementation, please use free R2S API instead, which is much more flexible than CMC's R2S. All data sent by the Q must be the same type declared during Q creation phase. It can be a simple data variable like a jar integer long, or it can be a structure. Within CMC's R2S API, there are two types of the Qs. The message Q, where you can send only the integer data or a pointer or a structure, or mail, where you can send the memory blocks. We will focus within this training on this first type, so the message Q. Length of the Q is declared during creation phase and is defined as a number of items which will be sent via Q. Operations with the Qs are performed in a critical sections using base pre-register, so we are sure that none other tasks nor the interrupts which can perform any operations on the OS will be executed during the operations on the Q. Tasks can be blocked on operation on the Q, so on sending or receiving the data with a given timeout or infinitely. If we have multiple tasks which are blocked on waiting or for receiving or sending the data within the Q, the only task with the highest priority will be unlocked when the data will be available. So the first criteria to select the task which would cooperate with the Q is the priority. Highest priority task is always selected first. Then if we have all of the tasks with the same priority, the task that has been waiting for the longest time will be unlocked. Here we can see a typical use case of the Q. In this example we will have the following components. Q with length of four elements the same size, a sender task and a receiver task. At the beginning sender task is sending message 1 to the Q. Receiver is not yet requesting the data. In the next phase sender task is sending message 2 to the Q. After this we have two components in the Q. As it is a FIFO, so first in first out, message 1 will be read as a first one. In the third phase sender is not sending the data but receiver task gets one message from the Q. After this message 2 becomes a first component to be read and it is done in the fourth phase. In the fifth phase we have an empty Q and no activity neither on sender nor on receiver task. Let's have a look how we need to create the Q. So it is very similar to the tasks. So to create the Q we need to specify some attributes of it. So in this case it's much more simple because we are specifying only the Q name, in this case Q1, and then we are executing the function OSMessageQNew with three arguments. The first one is let's say the maximum number of the messages in the Q. Then we need to specify what is the message size in bytes. So it is the single component within the Q, its size. And then the third component is let's say the pointer to the attributes which is specified. So in this case it is the structure that contains the name and some other components which would be filled in during the creation of the Q. As a return of this function we are receiving the Q handle, start within the type OSMessageQID underscore t. If we will receive null it would mean that there is a problem with the creation of the Q and most probably we've got some issues with the memory allocation. So we need to verify whether there is enough memory space to allocate new resources. To delete the Q we need to execute the function OSMessageQDelete and the only argument is a Q handle which has been received during the creation of the Q. And the return value is OSStatus underscore t which informs us about the successfully or not operation of this deletion. So once it is OSOK it's 0. That means that everything went correctly and the Q has been deleted. Otherwise there were some issues with the operation. Let's have a look on two basic functions which can be used together with the Qs. The functions to put and receive the data to and from the Q. To put the data into the Q we've got a dedicated function OSMessageQPut. It is in fact calling QXQSend within 3R2S API. This function requires four arguments. The first one is a handle to the Q. The second one is a pointer to the buffer of the message which we would like to send into the Q. Then there is a message priority which is not used within the current implementation. And the last one is a timeout in milliseconds to wait till operation will be completed. And here is the important message. If our function will be not successful so it will be not possible to put the data within the given timeout the OSStatus underscore t returned value will be different from 0. It will be OSTimeout. So it is very important while coding the application with using OS functions to check the return value of the functions especially those OSStatus underscore t type. Because in this case we will have the information whether the function was successful or not. Okay, let's continue. So there is how to receive the data from the Q. For this we've got a dedicated function OSMessageQGet return value is exactly the same. So this is OSStatus underscore t type. And again we need four arguments. Starting from the Q handle. Then the pointer to the buffer for the message to get from the Q. Then the message priority which is not used and should be null. And at the end they are receiving timeout given in milliseconds. We've got some more functions which can operate on the Qs which is worth to know. So for example we've got a dedicated function to reset a message Q to initial empty state. For this we need to execute OSMessageQ reset. And as an argument we need to specify the Q handle. And the status of the operation is classical OSStatus underscore t. Then we can get the number of messages stored in the Q by calling the function OSMessageQ getCount. And again we need only the Q handle. And we can have the available space in the message Q. So for this we've got the function OSMessageQ getSpace.  So it can be useful in some particular cases when we would like to have more control on the Q which is operational for example by many tasks. Let's have a look on the Q parameters which are grouped within the structure of OSMessageQ 8tr underscore t defined within cmcs underscore os2.h file. We have seen this already within the creation of the Q. At that time we have specified within this structure only the name. And as you can see this is the only configurable part which is available within the Q by mix. And the rest of the attributes are set by the application after the creation of the Q. So from those we can see the attribute bits. Then we see the pointer to the Q control block area. Then we can see the control block size of the Q. Then we can see the pointer to the Q data storage area. So the storage on the objects of the data send via the Q and would be stored. And then we can see the size, the data size area of the Q. So those components are filled in by the code after the creation of the Q. We need to specify only the Q name. Here on the slide we can see the Q structure management. So in fact it is the control block of the Q. So it's similar to task control block but this one is in fact Q control block. It is defined within the Q.c file. And as you can see it has multiple fields starting from the pointer to the beginning of the Q storage area. Then we've got the pointer to the end in the Q storage area. So the head and tail like in the classical pipe. And then we've got some additional pointers which are reflecting the number of the three, let's say slots within the Q. Important message is within the frame where you can find let's say two lists. The first one is the list of let's say the tasks which are waiting to send data to the Q. It is stored in a priority order. And the second one is the list of the tasks that are blocked waiting to read from the Q. It is stored as well in a priority order. And based on these ones the Q can exchange the data of the task. Based on this list the selection is done. Which task can take the data or can send the data to the Q. Then we've got the number of the items currently stored within the Q. We've got the length of the Q defined as a number of items to be hold, not in a number of bytes. This is important. Then there is a size of the each item which is stored within the Q. This is very important. And the rest of the components are not that important. And the last three, please have a look, are related to the tracing possibility which is allowed within 3R2S. So once you use trace facility you have additionally Q number, Q type and some additional parameter which can be monitored within the debug session. So those would be assigned to Q and can be monitored within the debug session. So it can be helpful during the development phase. Here we can see some comparisons of Q functions across different APIs. Please notice that within 3R2S API we have much more possible options of data management within the Q. As you can see we have some options Q send to back, Q send to front, Q peak which means that we can have a look what is inside the Q without taking the data from it. It is not the case of CMC's OS API which contains much less functions on this. But what is positive within CMC's OS is that it is not necessary for us to pay attention which function we need to select once we call it from the task and which one once we call it from interrupt. The selection is done automatically within the function. It is defined within CMC's underscore OS dot C file. Thank you for watching this video.