1
00:00:00,360 --> 00:00:07,590
Hello, welcome back and listen, we going to see how to work with mutex we saw how to use semaphores.

2
00:00:08,100 --> 00:00:14,910
I've made a copy of our last project, which is our always for and I've called this one which mutex

3
00:00:14,910 --> 00:00:15,840
it is over here.

4
00:00:16,230 --> 00:00:18,740
I'm going to expand it and open the main door.

5
00:00:18,750 --> 00:00:20,100
See far from here.

6
00:00:22,260 --> 00:00:31,530
And we simply going to convert this project to a mutex so a mutex takes a simple structure, a simple

7
00:00:31,530 --> 00:00:35,070
structure of attributes we need.

8
00:00:35,070 --> 00:00:38,460
No, actually let's go and find a mutex.

9
00:00:39,120 --> 00:00:40,590
This is all documentation.

10
00:00:42,750 --> 00:00:44,890
We have to track everything down together.

11
00:00:45,030 --> 00:00:45,980
It's better that way.

12
00:00:50,270 --> 00:00:52,040
So this is mutex management.

13
00:00:54,290 --> 00:00:58,070
OK, so the mutex has an attribute.

14
00:00:59,060 --> 00:01:03,560
OK, and then there is the new text, new function, let's see this.

15
00:01:05,680 --> 00:01:07,900
The function simply takes the attributes.

16
00:01:08,770 --> 00:01:17,500
OK, so over here we have an attribute for our semaphore, which we call currently, which we are calling

17
00:01:17,500 --> 00:01:18,960
you at for our troops.

18
00:01:19,870 --> 00:01:23,410
So we're going to replace this with a mutex attribute.

19
00:01:23,770 --> 00:01:27,860
So this attribute is of type always mutex Atiyyah.

20
00:01:29,590 --> 00:01:35,800
So I simply replace this with a mutex attribute, and I'm giving this a new name, you automatics,

21
00:01:36,370 --> 00:01:39,310
and then the name of the troops or the attributes is you.

22
00:01:39,640 --> 00:01:41,440
You are mutex attributes.

23
00:01:42,220 --> 00:01:47,200
So then I'm going to come down here to create the mutex where we created a SEMAFO.

24
00:01:48,040 --> 00:01:51,460
Over here, we simply replace the function here.

25
00:01:53,780 --> 00:01:54,860
With mutex.

26
00:01:58,940 --> 00:02:08,390
So before we do that, we have to create an I.D. to hold our mutex so we're going to create a US mutex

27
00:02:08,390 --> 00:02:09,890
ID data type.

28
00:02:11,030 --> 00:02:17,210
Over here, we have a semaphore type, we're going to delete this and have a mutex type going to call

29
00:02:17,210 --> 00:02:19,520
this, you add MOUT.

30
00:02:20,210 --> 00:02:22,250
OK, right.

31
00:02:22,850 --> 00:02:27,290
So once this is done, we'll go ahead to create a new mutex.

32
00:02:28,010 --> 00:02:31,040
So I'll scroll down here where we created a SEMAFO.

33
00:02:31,050 --> 00:02:34,340
I'm going to come in this out and create a new mutex.

34
00:02:35,700 --> 00:02:38,800
Then, like we said, simply takes the attributes as argument.

35
00:02:38,840 --> 00:02:40,910
This what we saw in the documentation.

36
00:02:41,490 --> 00:02:50,690
OK, so once this is done, we can simply go and replace our SEMAFO Akwa of release with mutex.

37
00:02:51,020 --> 00:02:57,080
So over here, rather than see SEMAFO acquire, we simply save mutex acquire.

38
00:03:01,840 --> 00:03:11,260
Always mutex Akwa and rather than see always SEMAFO release, you say always mutex release.

39
00:03:13,700 --> 00:03:21,340
And then we do it for the other one, this one here, red, a little controller ask rather than, say,

40
00:03:21,360 --> 00:03:31,580
WMI for Akwa you say always mutex Akwa and we release by calling the voice always mutex release function

41
00:03:31,580 --> 00:03:32,150
like this.

42
00:03:33,230 --> 00:03:35,150
OK, let's do wait and see what we've got.

43
00:03:37,280 --> 00:03:38,390
Click over here to build.

44
00:03:43,510 --> 00:03:44,170
It's built in.

45
00:03:47,270 --> 00:03:51,660
Oh, OK, so I forgot to change the ID of the function.

46
00:03:52,190 --> 00:03:56,870
He has to be the mutex ID you are to ID a copy this.

47
00:03:57,910 --> 00:04:02,560
Replace it here and replace it here, let's build.

48
00:04:07,380 --> 00:04:08,280
Click here to build.

49
00:04:16,360 --> 00:04:24,970
Oh, sorry about that, I forgot to replace in the release, so we acquire and then we release, we

50
00:04:24,970 --> 00:04:26,560
acquire and then we release.

51
00:04:30,990 --> 00:04:31,770
We had to build.

52
00:04:46,720 --> 00:04:56,050
It's pure successfully, we're going to run this right click over here, I'll see dbag us SDM 30 to.

53
00:04:57,340 --> 00:04:58,840
So like this, forty three.

54
00:05:01,160 --> 00:05:02,960
It's opening, I say, OK.

55
00:05:12,040 --> 00:05:13,210
Well, click here to switch.

56
00:05:21,860 --> 00:05:22,360
Then.

57
00:05:23,630 --> 00:05:27,200
I screw this over here, I'll minimize this.

58
00:05:31,540 --> 00:05:37,930
I'm going to clear this and then I'll pull this over here and then I'll click to run.

59
00:05:42,950 --> 00:05:43,930
Nothing is running.

60
00:05:44,360 --> 00:05:45,590
Let's pause and see.

61
00:05:48,220 --> 00:05:52,150
How were you at, says, waiting for the UDS?

62
00:05:53,750 --> 00:05:54,270
OK.

63
00:05:54,440 --> 00:05:55,520
The port is closed.

64
00:05:56,560 --> 00:05:59,360
I'll click to run and then open up ports for the.

65
00:06:00,440 --> 00:06:03,160
As you can see, we have the same results as I was.

66
00:06:04,160 --> 00:06:06,260
OK, so this how to use the mutex.

67
00:06:06,950 --> 00:06:10,190
So there is and I'll see you later.

68
00:06:10,220 --> 00:06:10,960
Have a nice day.
