1
00:00:01,160 --> 00:00:02,150
Hello, welcome back.

2
00:00:02,360 --> 00:00:11,060
In this lesson, we go in to see how to work with semaphores using our Simms's outer space and going

3
00:00:11,070 --> 00:00:13,250
to make a copy of the last projects over here.

4
00:00:18,130 --> 00:00:20,890
My computer and I responded just a moment.

5
00:00:25,660 --> 00:00:33,580
OK, I'm going to right click, copy and paste over here, I call this 42.

6
00:00:38,160 --> 00:00:38,970
I call this.

7
00:00:42,460 --> 00:00:43,630
Over semaphores.

8
00:00:50,580 --> 00:00:51,180
Like this.

9
00:00:53,070 --> 00:00:58,770
OK, so we're going to expand this and open our mind to see fall over here.

10
00:01:03,920 --> 00:01:12,530
And this a copy of our last project in the last project we created, The Time is OK, and also in this

11
00:01:12,530 --> 00:01:13,760
project we have.

12
00:01:15,620 --> 00:01:19,610
We have four tasks and they all have different priorities.

13
00:01:20,440 --> 00:01:22,740
We can send them back to normal priority.

14
00:01:22,790 --> 00:01:27,310
We can either let them or have the same priority or keep this.

15
00:01:27,320 --> 00:01:33,320
But I'm going to set all of them to priority normal because we wanted to run a different experiment

16
00:01:33,320 --> 00:01:34,820
when we changed our priorities.

17
00:01:35,150 --> 00:01:40,810
So we have four tasks of the same priority and we have two timers.

18
00:01:41,210 --> 00:01:42,250
We don't need a timers.

19
00:01:42,260 --> 00:01:43,820
We can keep it without cleaning it.

20
00:01:44,340 --> 00:01:48,190
OK, so we are here to find out how to deal with semaphores.

21
00:01:48,710 --> 00:01:56,970
So semaphores, we have to go to our documentation to see what apps we have available for us.

22
00:01:57,650 --> 00:01:58,940
OK, I'll come over here.

23
00:02:00,540 --> 00:02:04,440
And then there is semaphores punishment here, click this dropdown.

24
00:02:08,510 --> 00:02:09,620
And over here.

25
00:02:11,680 --> 00:02:16,960
Let's see the SEMAFO Hassan attributes just like the task, so let's find out what his attributes looks

26
00:02:16,960 --> 00:02:17,260
like.

27
00:02:19,340 --> 00:02:20,420
So this attributes.

28
00:02:21,460 --> 00:02:26,890
The name of the SEMAFO attributes bit memory control block the size provided.

29
00:02:27,250 --> 00:02:29,820
OK, so we just going to give our SEMAFO and name.

30
00:02:29,860 --> 00:02:32,050
We're not going to assign the other attributes.

31
00:02:32,590 --> 00:02:37,240
OK, so now let's see this function or SEMAFO new see.

32
00:02:39,330 --> 00:02:40,800
So 074 new.

33
00:02:41,970 --> 00:02:49,230
This function creates an initializes a SEMAFO object, so this is what we would use to create our semaphore,

34
00:02:49,770 --> 00:02:52,520
and this function, as we can see, takes three arguments.

35
00:02:52,890 --> 00:02:56,010
The first argument is the maximum count of the SEMAFO.

36
00:02:57,100 --> 00:03:01,300
And then the second argument is the initial count, and the third argument is the attributes.

37
00:03:02,920 --> 00:03:10,870
The attribute structure, so from here, we know we are creating a account in semaphore, right, so

38
00:03:10,900 --> 00:03:17,290
there is maximum initial count and then the SEMAFO attribute, such as the name and the other stuff

39
00:03:17,290 --> 00:03:18,710
kept in the attribute structure.

40
00:03:19,240 --> 00:03:28,030
OK, and then of course, after that we would have our SEMAFO or SEMAFO receive and some of our acquire

41
00:03:28,360 --> 00:03:36,460
and then the other functions gets count, delete, SEMAFO gets the name of SEMAFO, etc. So we know

42
00:03:36,460 --> 00:03:36,990
what to do.

43
00:03:37,240 --> 00:03:42,520
So we have to declare an attribute, just like our tasks here have attributes.

44
00:03:43,720 --> 00:03:47,820
The SEMAFO has its own attributes and the attribute structure has its own members.

45
00:03:48,190 --> 00:03:53,350
But what are we going to do here is just create we're going to create a simple attribute.

46
00:03:53,380 --> 00:03:54,510
This will have just a name.

47
00:03:54,940 --> 00:03:56,020
So come up here.

48
00:03:56,470 --> 00:04:02,260
I'll have this attribute SEMAFO attributes I could have created inside of me and function.

49
00:04:02,260 --> 00:04:04,150
It is fine, but I'm creating it here.

50
00:04:04,750 --> 00:04:12,880
OK, and we given this the name you are SEMAFO and then we're going to declare a Hando or a SEMAFO idee.

51
00:04:13,210 --> 00:04:22,470
So Hindoos that we had in the native free Arktos APIs are called IDRs in the Simms's Arktos space.

52
00:04:22,840 --> 00:04:26,860
So we create an idea for some of what we're going to call this UAT.

53
00:04:26,860 --> 00:04:27,910
Same idea.

54
00:04:28,780 --> 00:04:39,460
Once that is done, we going to create our SEMAFO, we're going to create a SEMAFO of a maximum count

55
00:04:39,460 --> 00:04:45,130
of one and we're going to set initial count to one as well so that our first task will be to know the

56
00:04:45,130 --> 00:04:46,620
SEMAFO would have access to it.

57
00:04:46,990 --> 00:04:49,750
So I'm going to come down here before we start the scheduler.

58
00:04:50,110 --> 00:04:51,370
We create our SEMAFO.

59
00:04:52,670 --> 00:04:59,990
And well, criticism for the handle of the SEMAFO is going to be retained and stored in our new outswim

60
00:04:59,990 --> 00:05:04,520
ID or the idea of the SEMAFO to use the language of Simms's Arktos.

61
00:05:04,880 --> 00:05:07,460
The ID is going to be retained and we're going to start it over here.

62
00:05:08,000 --> 00:05:14,930
OK, so then we're going to use this SEMAFO to print something to our UAT.

63
00:05:16,790 --> 00:05:17,240
So.

64
00:05:18,650 --> 00:05:20,810
So far, our experiment has been.

65
00:05:21,870 --> 00:05:23,490
You know, incrementing our.

66
00:05:26,360 --> 00:05:28,530
Our task profile is with this delay.

67
00:05:28,550 --> 00:05:33,980
I'm going to delete all of our pseudo delay from each and every function, so I delete this first one,

68
00:05:34,670 --> 00:05:36,080
delete this second one.

69
00:05:37,190 --> 00:05:38,510
Delete this third one.

70
00:05:40,430 --> 00:05:42,730
And then there should be a last one to leave this one.

71
00:05:43,480 --> 00:05:50,320
OK, so each task is simply going to take the SEMAFO and imprint's to the serial port and then release

72
00:05:50,320 --> 00:05:50,970
the SEMAFO.

73
00:05:51,580 --> 00:05:58,120
So just like we did in our native apps, I'm going to say, oh, SEMAFO acquire.

74
00:05:58,780 --> 00:06:00,460
And this takes two arguments.

75
00:06:00,580 --> 00:06:06,700
The idea of the semaphore you wish to acquire and then the weeks time we saying wait forever.

76
00:06:06,730 --> 00:06:10,480
So we all get stuck here until we are able to acquire the SEMAFO.

77
00:06:10,900 --> 00:06:17,350
Once we do that, we're going to print this blue task to the new art and we're going to release the

78
00:06:17,350 --> 00:06:21,220
SEMAFO so that the next task will have access to it.

79
00:06:21,700 --> 00:06:26,730
And the next one, which is read is going to acquire the SEMAFO as well.

80
00:06:27,520 --> 00:06:30,460
And then it will do the same thing after red.

81
00:06:31,330 --> 00:06:37,510
Then Orange would acquire the semaphore and we can let Orange and the others we can.

82
00:06:39,960 --> 00:06:44,340
We can pass it around, but let's experiment, we just these two tasks.

83
00:06:45,270 --> 00:06:45,870
OK.

84
00:06:49,470 --> 00:06:51,880
Let's see, what else are we missing?

85
00:06:52,260 --> 00:06:55,530
We are looking good, so I'm going to click here to build.

86
00:07:02,710 --> 00:07:04,990
OK, so because we deleted our.

87
00:07:06,060 --> 00:07:12,780
For int, because we deleted our four inch equals zero less than seven thousand, the delay, who gets

88
00:07:12,800 --> 00:07:15,500
in a warning of having this unused variable here?

89
00:07:15,510 --> 00:07:20,280
I'm going to delete each and every one of them of deleted the one in orange.

90
00:07:20,280 --> 00:07:21,650
I've deleted the one in green.

91
00:07:22,110 --> 00:07:25,260
I'll do that for blue and red.

92
00:07:25,500 --> 00:07:28,680
I'll delete this one here and see.

93
00:07:29,740 --> 00:07:31,760
I would like to read over here as well.

94
00:07:32,260 --> 00:07:35,380
And now let's do it again, click over here to build.

95
00:07:40,150 --> 00:07:41,420
It's built successfully.

96
00:07:42,710 --> 00:07:44,170
All right, click over here.

97
00:07:45,680 --> 00:07:51,370
And then I said, bug us a STEM 32 application also like this over here.

98
00:07:54,040 --> 00:07:55,240
And then I'll say, OK.

99
00:08:01,030 --> 00:08:01,810
It's open in.

100
00:08:03,370 --> 00:08:04,180
Quick to switch.

101
00:08:08,420 --> 00:08:10,250
And then I'm going to open real to.

102
00:08:19,120 --> 00:08:21,790
OK, this is real time from the last time we used it.

103
00:08:21,820 --> 00:08:29,320
I'm going to clear this, going to minimize this and I'm going to click play over here so we can see

104
00:08:29,920 --> 00:08:31,130
how our system is working.

105
00:08:31,940 --> 00:08:38,560
OK, so as you can see, red, blue, red, blue, red, blue, blue.

106
00:08:38,860 --> 00:08:39,960
We already know this.

107
00:08:40,360 --> 00:08:45,850
So now we know how to achieve this using the CMS artist API.

108
00:08:46,570 --> 00:08:48,250
OK, so that's all there is.

109
00:08:48,880 --> 00:08:50,200
And I've seen the next lesson.

110
00:08:50,260 --> 00:08:51,100
Have a nice day.
