and welcome to the program, Agriculture on the Move. I am Philip Sidney, your host, and I also like to welcome you to the program at the Command Center of the National Television Network, NTN. Today, our discussion surrounds the Fruit and the Vegetable Import Substitution Project. We also call it the Seven Crops Project. And with me to dissect that project is Mr. Kemuel Jabatis, who is the Chief Extension Officer and he's to my right. And in the center is Miss Adlin Yudovic, who is the coordinator of that project. And Mr. Thaddeus Constantine, who is the Acting Chief Enterprise Development Officer. And we all are from the Department of Agriculture, Fisheries, Natural Resources, and the Cooperatives. Gentlemen and lady, welcome to the program. Thank you. Adlin, as the coordinator, and of course, I know you have done quite a good job with that project. Tell St. Lucia the genesis of this project. Okay. Good morning again. Good afternoon. The project we're speaking about today is a project for enhancing the efficiency of production distribution supply chain in the fruit and vegetable sector. This project, as you said, is commonly called the Seven Crops Project. The project was conceptualized by the Ministry of Agriculture some years ago and we started it last year. That will be 2019. The main aim of the project is to reduce the importation of certain crops. We notice that our food import bill is very high. Up to last year, our food import bill was well over $367 million. And we notice that there is something that can be done within the Ministry. So this project is geared at doing just that, at reducing the food import bill through the increased production of these crops and increased consumption of these crops locally. Okay. Moving forward, so what was the strategy here in terms of the preparation of that project with the officers in the Ministry? Okay. The preparation started from obviously going into the data and seeing what crops have been, the traditional crops in St. Lucia. So we look at certain crops that we know that have been produced for, that have been produced for a long time, such as tomatoes, cabbage, lettuce, cantaloupe, honeydew, watermelon, pineapple. These are the main crops that we're looking at. So these crops are the crops that we have been pushing for a long time in St. Lucia as a Ministry. And the farmers have the know-how, the technical savvy to produce these crops and to produce them well. So we know that these crops are crops we consider, as I said, traditional crops and the importations still remain high. This is because of many reasons we could discuss later. But within the Ministry, we seek some assistance and we got this from the government of Taiwan through the ICDF office. So this project is funded by the Taiwan Technical Mission in St. Lucia. Okay. Okay, so from then on, you were able to link with the extension officers. Was there the ones that are driving that project? Definitely, definitely. The Ministry, different departments in the Ministry, different units are integral in this whole project. So we have extension, the extension officers. We have marketing unit. We have engineering. We also have research. So all the different units in the Ministry work. We work in sync to push this project forward and to make sure it's a success. Okay. Kamuel, as the Chief Extension Officer and driving that project, I'm sure there was a plan in terms of our production scheduling. Yes. Tell us exactly about this in terms of looking at where those crops are grown best in the ecological zones. All right, thank you. And thank you for having me here today. So when the project was conceptualized, we proceeded to look at the data in terms of, as Adlin rightly mentioned, to see what quantities were being imported. Because keep in mind, we were not really too concerned about what was already being produced because what was being produced was being absorbed by the existing markets, the hotel, the street markets and the supermarkets. So having gone through the data, we looked at what it is that was being imported. And we did engage the farming community in the early stages to indicate to farmers who might be interested. One of the things that we did and we continue to do at the inception stages, we got a sort of a verbal commitment from some of the farmers in terms of their capacity. Those who are already producing, do they have the capacity to expand by what acreage? Do you have an extra acre? Do you have an extra quarter acre? We also spoke with persons who perhaps were not traditionally producing the crop but were interested in producing maybe one, two or three of those. And we inquired as to what the acreage that they have available. Because it's one thing to decide that you're going to work towards increasing the production and productivity. But we don't do that as a ministry, we provide technical support services. So a major part of the process was to engage the farmers. So from early on, we got indication as to what they available acreages are and what sort of assistance that they would be looking for in terms of participation in the project. Having done that in the later stages up to more recently, we also have been engaging the farmers in terms of seeing what the schedules look like. What have they been, at what times of year we were able to get information as to what times of year they traditionally grown. Now, during the process, you come across farmers who have these historical ways of doing things at a particular time of year. But the crops that we are talking about are not seasonal. These crops can be grown year round under the right conditions. We also took a look at those people who have greenhouses, they protected agriculture.  Now we did a survey, I think, in the early 2000s and we had somewhere in the range of about 300 of those structures on Island. And we were able to engage some of the people and see what the conditions were in terms of scheduling production in those greenhouses at the appropriate time. And so a couple of things, we engaged the producers, we got an indication of what the available acreages were and what the available greenhouse facilities would be. And we used that to begin the process of deciding what number of acres we would need to cut off on that importation number that we were looking at for those specific crops. Well, how were you able to find out the acreages required at the specific time? The project, is it, there's a certain percent, is it 30% then that you're looking at or 40%? So what was the scheduling like? So initially when we started off, we used time series data. So we looked at the data from about 2015, 2016. So we run 2015 all the way to about 2018 in terms of what the importation numbers were. But we didn't just look at it on an annual basis, we also looked at it on a quarterly basis. The quarterly basis would help us to determine for every specific quarter what it is that we're importing as a proxy. It's not absolutely correct, but it's a proxy that allows you to determine, okay, for the first quarter, we were looking at 150,000 pounds of a particular crop that redounds to about 15 acres. So for that quarter, you target that number of acres. So this is the approach that we generally use in terms of determining what it is that we want to put in the ground. Because like I'm repeating, we're not looking at what's already been sold locally. What we're looking to do is to look at what has been imported and to tap into that import market and reduce it. Okay, with that now, obviously it's market driven. Yes, okay. Now, Tadias, I know that from the farm to the market, it has to be organized, okay? You're dealing with the hotels. You're dealing, of course, with our new marketing entity that is about to come on stream, okay? How is that organized? How it must have a format? How were you able to be in sync from the production to the market? And to ensure that the hotel gets what they want on time. Okay, so within the market, we already had a lot of existing contracts where farmers already had the arrangements that they had already set up through the hotels and through the wholesalers. And these were investigated. But along with that, one of the things that happened is because we realized within the food chain, and that's not only for these seven crops. For all of the crops that we produce on the island, we have problems with potential contaminants, biological, chemical, physical contaminants that get into the food chain and that affect the quality of the end product. And so along with investigating what was already happening and strengthening that, these relationships, we also looked at how we could have strengthened the market in board, the San Lucia market in board. The San Lucia market in board is a key player in the agricultural landscape because it provides a secure market for our farmers. And it is one of the few markets that we within the government and service can use to intervene within the sector and to regularize things. And so one of the activities that was first performed was to put a pack house in within the San Lucia market in board. We're up to international standards. As we speak, it's been finished and the training's been done to ensure that the staff within the market in board are able to manage the pack house up to an international standard to ensure that we have safety within our food chain. And so one of the ways we have looked at this seven crops project is it's a chance for us to ensure we have greater food safety. And to use the lessons learned later on in the other crops that we're going to look at. So that was a key component. Firstly, understanding the market, the landscape. We had our teams going out doing surveys, interviews. We compiled that information. And from there, we saw a number of challenges within the market. For example, the hotels had challenges with lettuce. Lettuce is a very perishable crop. And out of there, we were able now to rethink our work programs within the Ministry of Agriculture and look at the new challenges that some of them we were aware of, some we were not. And also do the same for the marketing net. To ensure that the end product is at the standard of the internationally imported product. Okay, but with marketing, I don't want to mention marketing board. For me, that is no more. Yes, yes. People don't want to hear that name anymore. They will get a new name soon, board. So for now, I think we should look at it as the new marketing entity. Entity, yes. That's what we're looking at. And I'm hoping they find a proper name because trust me, farmers out there do not want to hear.  But I'm happy to hear the restructuring of it. But then, will a marketing board be the one to avoid many farmers going to the hotels to sell so that they can come to the marketing board and the hotels now can purchase via the marketing board? Okay, so ideally we would encourage that scenario because we do not want the problems getting to the hotels though. We want to be able to nip these problems in the bud before they get to the hotel. So with the pack house that has been established at the marketing board, we would now be able to ensure that the end product is of the desired quality. It is a challenge to be able to tell, we cannot always tell the hotelier and also the farmer to not enter into contracts. And these contracts, we're in the ministry, we have to do our best to assist both parties within these contracts so that the contracts are fulfilled to the best ability. But as a ministry going forward, we are looking at this marketing entity as a chance to revolutionize farming. A lot of changes have been made. One of the most significant being the repayment schedule. So our farmers had sometimes a three-month turnaround. That's a three-month turnaround has now been moved through the very hard work of a number of hardworking people in there. It has been moved to 14 days. And so within 14 days, our farmers can now expect a paycheck from the new entity. Another thing that also happened because of the beautiful work that was done by Adeline and the team is that within our COVID response, that entity was able to step up and to step up in a very big way for the island. And it occurs well for us that the work that we do can bring us comfort in times of distress. And so we will continue striving to strengthen that new entity. I know Adeline will talk a little bit about some of the databases that we're preparing and how these are going to work. And along with that, we also have a number of young entrepreneurs that are coming into the fore. We have one, Fresh Street Caribbean, young Saint Lucien, who has released a website. And we're trying to assist him with his networking. And he has a very beautiful product. And it's an online market where there's no need to go out of your house. You could do everything from the comfort of your company. We have another set of young men who have organized themselves into a group called GURU and who are releasing an online app. And that app now would allow our farmers and our hoteliers and our wholesalers to interact. So the market is very dynamic. New entity plays a very key role. However, we have to try to support all of the different aspects of the market. Great. Adeline, going back a bit, we're still in pre-COVID mood. What assistance were given by the Taiwanese, all right, in that project? I also heard about the hoop greenhouse. Could you mention all of this? Okay. The assistance given range from input assistance. Most farmers got some assistance with ground cover that was in the beginning of the project. Farmers got assistance with seeds. Other farmers got assistance with just the different agrochemicals that were required for production. In most cases, we came in with training for the farmers because we recognized when we were doing our different database surveys and so on that some farmers were registered in the ministry but they didn't receive any official training. From the different discussions we've had the different purchasers, like the different soil markets or hotels, they notice a difference between the farmers who are trained vis-a-vis those who are untrained. So we recognize that early and we embarked on a series of training for the farmers. The training included good agriculture practices, safe use of pesticides, post harvest handling, and a whole gamut of topics, let's say that the farmers were needed to bring them up to what the expectations of the markets were. So the farmers received that and it was very well received. Farmers gave extremely good reviews about these trainings and we proceeded also with pineapple training. We noticed that in the sector, there was the different shortcomings when it came to the different knowledge, the knowledge gaps from the farmers in the right time for even for harvesting to flower induction to cause early onset of fruiting and so on. So we did all this kind of training with the farmers and also in the hoop greenhouses, as you mentioned. So I'll speak about the hoop greenhouses. This is a new technology that's been introduced to our environment. It originated from Taiwan. So traditionally in Taiwan, it's used for cantaloupe and honeydew. So we continue along these same lines because this is one of the crops that we are looking at. And so far we did one round of experiments so far under these greenhouses with the same cantaloupe and honeydew. We have established 16 of these greenhouses around the island in different microclimates. When I say microclimates, I mean in areas that are high elevation as compared to low elevation, in areas that are considered hotter, like you know, Schroesel area and a cooler area like in Souffre or Babuno or somewhere like that, you know, like a Basso or some place like that, right? So we're doing that experiment right now and so far the results are very, very encouraging. We're noticing that the marketable yield is better. That means you have less rejects. We've seen that even the consistency in the fruit size is better under these greenhouses. We've seen also that even the taste is coming out a bit sweeter because it provides some shelter from the different elements. So everything is coming out better for us so far. And it looks well. So we're going into our second round of trials for the rainy season now, which is really what we're trying to target. So we did the dry season one already and then we're coming out of that now. That was good. So we're expecting even better results for the rainy season trials, all right? So in each plot we have a control plot where we could see what is the normal husbandry practices and we're doing the trial with the hook greenhouses. So with that, these are just three of the interventions so far, but they have several other interventions that I'll speak of later, such as the AIR system. Traditionally speaking earlier about the pack houses, I should mention that in the pack house, we also have a test room. All right, we should not forget that because every conversation is about chemical residue and so on. So in the pack house, we have the ability to do a rapid test, right? And to see if there are any chemicals in these fruits and in these crops, right? So we have lots of different interventions that we're looking at, which will go a long way in improving our whole agriculture sector. Great, I'll come back to this testing because that is crucial, right? Because our consumers are very concerned now. Yes, we are. As to the pesticides and the hash ones that we use and they're very concerned about that. We've only have this thing in terms of the gestational period of the crop and stuff like this. But Kimwell, your officers, okay, they have adapted this new technology. They're also involving the same crop project. Prior to COVID, are you, how many farmers can you see that adopted the project? And what were the challenges? Okay, so when the project roll out, it was our intention to identify basically all persons who were involved in the cultivation of these crops. Having identified all the persons, then we were able to sift out and see who would be interested in participating. Like any project, sometimes they expected timelines are not met. So whereas we anticipated we would have started all the way in early 2019, we really didn't start off until June 2019. What it did is it caused a little frustration. So for example, we're referring to the Hoops greenhouses that we're talking about. The farmers, like anything else, are excited. They've committed themselves, they've committed their space. There's a slight delay in terms of projected dates for setting up. And so we've had to navigate through this. We've had to negotiate with the farmers and help them appreciate that that sort of delay will take place. And so the field officers have been out there doing their utmost best to ensure that when the promises have been made, as far as possible, that we actually upkeep those promises in terms of deliverables. Like anything else, there's some persons who set off well. So we've had one or two persons who probably just came off and said, I'm not interested anymore. But we're hoping that the success stories of the participants, those who are actively participating, is gonna drop persons back into participating in the project and its outputs. I want our audience to bear in mind, because very often I think we short change the project by calling it seven crops and import substitution. A couple key components of the project is improve production efficiency. So when you hear us speak of using ground cover, a person growing those melons without the ground cover could easily lose any upwards of 40% just because it's interacting with the soil. And so that is one step to improving efficiency. When you have the hoop greenhouses, the rainy season is upon coming, we have severe challenges maintaining production levels in that season. You introduce this greenhouse, it is anticipated that it will cut off the rain and give us a chance to maintain production levels and productivity. But one of the challenges that persons may not be aware of, the person who's not participating in actual production may not be aware of, is not that farmers are not establishing the crops in the rainy season. The crops are being established. The challenges we have to contend with the elements. And so that is where hopefully the hoop greenhouses coupled with ground cover, coupled with the training that we're offering to the farmers is gonna push us forward in terms of enhancing productivity. So they usually farmers get, perhaps maybe up to 50, 60% of the crops production potential. It is anticipated that if we use the right technologies that we could get a higher level, maybe at 80, 90% of the crops production potential which will be down to better returns. And for the consumer, maybe if the farmer is able to increase his productivity might be able to settle for a slightly less surprise which would be a benefit to our consumers. So the field officers now, we are working together with the project team because there is a project team. So a lot of the work being done at the field level in terms of organizing, in terms of informing, in terms of bringing those folks together, that will be the work of the field officers. And it has its challenges because sometimes schedules go awry and that sort of stuff. So part of our training as extension is to be able to negotiate with our clientele to help them calm down a bit when things do not fall into place. One of the problems I know, and I would say problem, challenges is the question of crop monitoring. It's a bit difficult to work with a traditional farmer who wants to plant everything. However, his ecological zone and soil conditions may be tuned to grow in Sikabich for that matter. But then you, did you get any problems with such farmers gravitating to this new project? So production monitoring and production scheduling have been huge challenges for us. Now tell you why. We obtain the data, we process the data, but because we do not make a purchase, sometimes the relationship with the farmer and the marketplace is not well organized. And so whereas we know what the farmer is producing by the time the buyer is ready, that relationship is, it goes awry. So what we've sought to do is, and again the project team has a data processing person on board, so the field officers have worked with that specific person on a, I think it was a monthly basis or there about, quarterly basis, we went out there and we've gathered information as to what is established, what is anticipated in terms of the crops, the quantities and that sort of stuff. The whole idea here is to sort of use that information to help persons navigate and prepare and to also reschedule for the next quarter. The challenge with that is we have, we have the sidebar people, the guys sitting on the rock who's of the opinion that he's gonna do whatever he has been doing traditionally and will not give any due cognizance or regard to any schedules. The market is relatively small, so any significant spike in increase in the short run will cause an oversupply. I'm sure consumers these days are very happy with cucumbers because they're coming out of our ears and we do not even import it, that's why it's not on the listing. And the same thing happens with watermelons and all the other crops. If we are not careful and the farmers will not give due regard to paying attention to scheduling, within short spaces we have these peaks and then when you come maybe like four weeks later you can't find the same crop that you will get in abundance because of limited storage space, limited processing, we have these dynamics. And so the field officers, although the data is being collected and processed, the dynamics that is required between the producer and the buyer, we still have to find ways to try and negotiate through that so that we do not get those peaks and those troughs that cause frustration for everybody. So, okay, now that links with marketing ball. The information that's collected is there that information sharing with the marketing entity in terms of scheduling markets for the hotels and other markets out there because they have to be that link. So is there, is there, is there? I'm gonna add links to that because the team that she works with has been connecting and also I think it's a good place to talk about the agricultural resources there. Correct, so let me do the areas. So let me do the areas. And you'll take a chat from there. Okay, so one of the tools that was afforded to us under this project was an agricultural resource system which is actually a very smart database. It's a database that will allow us, our farmers to interact with the extension officers more efficiently, allow our farmers to interact with the market more efficiently because the ARS sits at the Ministry of Agriculture on our service. However, it is shared, the information is shared with the marketing board and also the farmers have their app. So it is divided into a farmer's app, an extension officer's app and a website for the management. Within the ARS, one of the most beautiful components of this system is that it will produce a QR code with a batch number for each batch.  On his app, and it would automatically show up with a batch number and a QR code would begin. So every time you put in a new activity, that activity would be stored, your extension officer would be away, but also the marketing board, the marketing entity would be away and we admin would be away. So the information would be in real time but it would be shared on a common platform. And we're expecting this to really revolutionize the way we work in San Rusya. For too long our farmers have been trying to call, they have the crop and two weeks before they call around and then they call us at the marketing office and then I have to put an officer to find a market for them. I think these days are going to be gone because our market, our buyer and our producer would be able to be in contact with our extension officers providing that middleman support service. But along with that, because of the batch number that is provided by the QR code, now the consumer would now be able to scan the product and would be able to see what happened to that product. When was it harvested? What did they put in it? But it would also open up the door for exports. And it's an area that we have not paid much attention to it within our seven crops project because we've been focused on fixing our local market and fixing our production, bringing our production up to that international standard. But it will also open up the door for our exports because now one of our biggest challenges was our lack of pack houses and also lack of traceability in our agricultural sector. And so now exports in Russia can now take these crops and start to run with them. No longer worrying about having to find a pack house for inspections and having to find farmers that keep records. Automatically all our farmers will be keeping records. So this is one of the more beautiful tools that has come out of this project and I can assure you, we are not going to let you go to waste. We are going to put it to the maximum use. Great. The lady? Okay, so let me advertise, you can come to advertise. That the name of this app, it should be called ifarm.govt.lc. So the extension officers as Thaddeus rightly said will have access. The farmers will have access to even advertise what they have ahead of it coming out in terms of the harvest date. The ministry will be able to see what's on the ground in real time, as he mentioned. And we could run reports on what's happening. If we want to see what's happening in watermelon, we could run a report on that to see when it's going to come out, what's going to happen to watermelon and we could run projections as to what will happen in this sector. Like anything else we do, and we do know that we have unforeseen, like in weather systems, pre-elastic, what have you. But then, if everything works properly, this system is going to revolutionize how we do business in agriculture. It will allow us further to even analyze what's happening. Just sit down there and see everything. And as I said, I'm very, very excited about that app that's coming out. We'll have a mobile app, we'll have farmers on the field could put it in. It should allow the extension officers. Then the extension officers have to be proactive now and go and see what's happening there in the field because the farmers will have access equally like us. So this one, as I said, is iFarm.govt.lc. We anticipate that at the end of August, it should be ready for the grant and rolling out there for use of the public. I'm happy for that because we see one of the things I have conceptualized is that should be able to lure young people into agriculture because it's new technology that's coming on the stream. And that is what, the dream agriculture is no more. You know what I mean, it's now we are moving fast. How long is that project? Project is three years. So we had last year, this year and next year. Okay, what happens after that? Well, we expect that, like anything like that, we'll see, we'll do an analysis of the data, post-mortem, right, a sport, right? To see what we could do differently. And we also have other crops as well. That's right. You know, we don't have only seven crops. We have just about 21 crops in our food baskets right now. So we look at these other crops as well because I'm sure even from now, that project is going to be a success because we have lots of success stories already. In fact, before we get into the post-COVID, tell us a success story with the lowering of the food import bill as far as those crops are concerned. Okay, so last year, as I said, we had many interventions with the farmers from training to input supply, to substitution of different materials that needed. And we realized that our target for the first year was very realistic. We had a 5% expectation for the food import bill for these seven crops because we knew that we had lots of different surveys and database to come up with and to make sure our baselines are right. So we did reach our goal for 4.75% reduction in the food import bill. Beautiful. Well said. So exact 4.75%. So this year, I know that we will not might not reach our goal of our 10% to 15% because of COVID, but we will pick up as we go along because the hotels are reopening, the store markets and the restaurants are buying more now. And we expect that we could reach, maybe close to our target, but our ultimate target is 30% reduction in the three years, right? And we are projecting more, but we have to remain at least realistic for now. Yes, because it's a new project and we have to go and learn as we go along. Great. Good. COVID hit. Hotels are closed. Yes. What were your challenges from a marketing standpoint? From the marketing standpoint was, like you said, availability of markets. Our farmers were clamoring for markets. With the hotels being shut and so abruptly, it didn't give them a chance to plan and to look at a second option. And luckily, our marketing entity was there. During the time of the 24-hour lockdown, the marketing entity continued its work. So the Ministry of Agriculture with the support of NIMO, NIMO issued passes to our farming community and also to the marketing entity, the workers at the marketing entity. So the marketing entity went island wide. They bought produce from the farmers. A lot of that produce became part of our care packages that was then taken to the communities to ensure that- What are the care packages? So the care packages was, it's a system that was developed by the Prime Minister's office to give some kind of relief during COVID. And it constituted putting a number of food items. They were actually listed along with, to ensure that we have a good balance of protein. We have carbohydrates and we have our fruits and our vegetables. So the marketing entity, the marketing board, were responsible for putting these packages together. The fish was produced, provided by Lushan Blue Ocean. And then some arrangement was made for chicken and eggs. And then the marketing entity put these packages together and these packages were collected and distributed throughout the communities. It's still ongoing. It's still ongoing? Yes, it's the end of September, I think. Yes. So we do 1,000 a month. A week. A week. A week. A week. A week. A week. A week. A week. A week. A week. 24 hours of them caught them by surprise. Our farmers were still able to sell to the new entity. And that new entity was now able to use that produce that was purchased from the farmers to ensure that comfort was brought to a lot of San Doshan families. So with COVID, we saw a new use for that great tool that we had that we never really used, which would be our marketing board. Our marketing board really stepped up in a very big way. And they continue ensuring that there is a market for our farmers. Now the traditional markets, some of the traditional markets never shut down really to talk about for not for a long period. Like Massey continued doing the good work that they do with the farmers, ensuring that they provide a home for a lot of our farmers. So a lot of our farmers work directly with Massey. And then we also had some of the players being CPJ, Transpacary, Ben Lizzie, Lagood, providing a market for some of the farmers. So we did see some contraction within the market, but also we did see the market evolve to meet the new circumstance. And our farmers also did move with that new environment. We also saw quite a lot of pineapples and tomatoes on the market during, but apparently all of this were sold, Mr. Cio. So again, COVID shows that nobody's expecting it. Farmers are not just producing for supermarkets and street markets. The hotel represents a significant portion of the distribution of produce. And so when that suddenly contracts as Constantine rightly points out, it now becomes available on the local street market. One of the things that we discovered and that is commendable and I would like to say, kudos to farmers, farmers, among the most resilient people. Some of our farmers were now able to very quickly go on their Facebook pages and begin to offer to a Facebook community that wish they had. It was not unusual for some of these farmers to have 150 packages ready for sale. Some of our farmers had their orders coming in through their Facebook pages. And making deliveries. Delivering home deliveries. Another thing that I think that the project contributed to with the farmers markets that we have been running pre-COVID, we saw a number of street side markets emerge. In some of the locations I could refer to would be like Miku and places like Piaesh or Zell and a few other places. It was a little challenging to go into the supermarkets because of all the restrictions, the lines were long. People needed fresh produce. So within those communities, the farmers came together in some cases and other cases, vendors set up within communities and farmers were able to bring in their produce. So I would like to really commend the farming public. As I said, necessity is the mother of inventions and these farmers, they rose up, they realized, look, there's nothing that we could do in terms of going to hotels, but we have produce and people want the produce, which was what was important. They had and was a lot of the crops that we had. The unfortunate thing I'll tell you about this scenario is that we were not able to capture the data in terms of the quantities sold through these channels. So in terms of our reporting, we may have a little bit of a challenge to tell St. Lucia Underwood, the quantity of produce that was traded during that period. But what we want to really celebrate is that initially it looked like it was all lost. The produce was ripening in the field and these guys got up and got a revelation. Some of the farmers worked together as a consortium. Some worked individually, but what it did was to allow persons to get rid of the produce distributed to the homes. And so I'd like to really commend the St. Lucia and farmers again for such initiatives. Let us go back to the farmers market, which is what we forgot to mention in the pre-COVID situation. What was the objective of the farmers market? Well, as Camero was referring to a while ago, we were expecting that farmers will get non-traditional markets, outlets for sale, because they have the traditional store markets, the restaurants, the hotels, but we're looking at community sales, sales at the community level, where persons in the community could access these foods more readily. So they could come in the farmers market, learn about the different crops that have been pushed right now, see different ways of preparing it as well, because part of the farmers market, we had the different processors coming in for sale and display of the items. We also had the schools taking part in almost like a competition to see who could prepare a beautiful, delicious dish out of the watermelon or the pineapple or whatever under the project. So the schools took part in that where they got a chance to show the creativity, right? And then we also had Ministry of Health coming on board with the different testings for diabetes and showing, yeah, the different discounted promotion and also showing the nutritive value of these crops and why they should be consumed and the different benefits for the health of our solutions, right? So the farmers market served many, many objectives, but the main one ultimately is to increase sales and increase consumptions of these seven crops. And that would, COVID, yes, it had its negativities, but it really opened our eyes. Yes, it did. But in fact, for years, we have been talking about eat fresh solutions best. Consume what we grow. It's healthier than what is important. We don't know what is important in terms of traceability. We don't know, but at least we know what we have here, all right? And we need to keep on. It shows this phase quite vividly. Post-COVID, I can recall it with the total lockdown. I remember my good friend, François, who was producing his seedlings down there. I mean, once in a while, the people were driving. And from the lockdown, there was traffic jam. Up to now, there's traffic jam, you know? So, let's just see you back here, Dardney, has come to the fore. Ah, back here, Dardney, back here, Dardney. Everybody's interested in this. Everybody is Dardney. Everybody. And thankfully, the ministry, we were in part prepared for it in terms of preparing people. We had these videos, these YouTube videos produced a while back that looked at issues of site selection, preparation of grow boxes, preparation of seedlings. I think we had about eight or so programs prepared, about half an hour each one of these. And the ones related to marketing and preservation we had not done. But what it allowed us to do was when COVID showed up and persons, the preppers began to realize like, look, we may have a challenge with availability of fruits, vegetables, herbs, and so on. Most persons started getting their hands dirty. Again, you were home. Going to the supermarket world could have been a frustration. The space was there. And so most persons who called, we referred them to take a look at these videos. I mean, some cases, some of the field officers were able to do some home visits, not very popular, but they were able to do some home visits. And of course we gave the public our commitment that if they needed support, all they had to do was call. I think the OECS also, with among its staff also rolled out a backyard gardening program. Initially we were a little concerned because when you have extensive backyard gardening taking place in an environment where your hotels are not in operation and you have no exports. And then we are asking on the Seven Crops project for the farmers to produce. To produce. Exactly, we were going to buy it. Exactly. But like I said, my explanation was, look, we have countless numbers of minibuses on the roads, but we have lots of motor cars, family cars. The minibuses still get to run. There's space in the environment.  I said, look, I don't think we have excesses of cars or transportation. All the cars run, everybody gets a job done. So same principle applies. The homeowner gets a personal gratification of having participated in something that's rewarding for them, both intrinsically and extrinsically. The farmer still has a group of persons who are not production savvy who are going to make the purchase and that sort of stuff. And so backyard gardening was a really welcome breath of fresh air during that period. And I think it is taking roots and I'm seeing a lot more people continue in it. The only unfortunate part about the backyard gardening is we're trying to restrict it to just crops, to a less extent livestock. And for the reason why we have to stress livestock to a less extent, particularly chicken, because of the restrictions and possible contamination created by these, and of course the nuisance created by the odors from certain animals. And so I'm hoping that persons don't get frustrated and say, well, I'm a livestock farmer, why am I not being allowed to cut it, to rare my chickens and so on. But I would like to celebrate all St. Lucian's, all home owners who during that period were able to go out there, get their hands dirty and get a greater appreciation for the commitment and hard work that is associated with food production and understanding according to Adeline. We used to say, eat what you grow, grow what you eat. Well, the mantra is eat what you know and know what you eat. And then eat fresh and it's just best. Eat fresh and it's just best. Can I forget that one? You can't forget that one. But you know what, the interesting thing is on that line, Mr. Constantine, don't forget the farmers till, my concern was the farmers not being able to sell the produce. And then here was the care packages, but there was also the quarantine facilities that had to be fed. Oh, yes, yes, yes. The quarantine facilities, they'd purchase very large amount of produce. And along with that, we did have a number of non-profit groups that did step up, one of them being IPA, Independent Processes Association. Oh, yes, in the big way. That stepped up in a very big way. Big way. And created a market for our farmers because they prepared lots and lots of meals. For the frontliners. For the frontliners, ensuring that our frontline staff were well fed. Because a lot of our frontline staff were not even able to go home. They were there for hours upon hours, shift upon shift. And so we had these non-profits stepping up. And that was, that was great. It was a great time. It was a time where we really saw San Lucien's being. And there was Comradry. Yes, yes. That was a good thing. For IPA, this is, I mean, we haven't said thank you at the Ministry of Agriculture. Yes, so we can say thank you to them now. Thank you to IPA for stepping up. Yes, yes. And they were newly, they're not even registered as yet. They're newly formed. We're just getting them organized. And they took step up in such a large way. So a lot of people stepped up. And like Emel said, you could have a lot of buses on the road, but you still have a lot of cars. Our householders, I would like to encourage them to think of tilapia for the backyard. Yes, yes. Shrimp. Yes. They do very well in the backyard. Aquaponics. Aquaponics, yes. That's what you need to do. Yeah, they need to do aquaponics. They need to investigate aquaponics. It's always good to supplement your income with a little production from your backyard. There will always be a market for our farmers. Absolutely. Absolutely. I think the first into backyard gardening has been a beautiful note. Actually, I think it will encourage local consumption. In fact, during that period, I noticed there were lots of postings, man. People actually showed their various skills in the making of the boxes and the tires, the tire culture, using the PVC pipes. Right.  Because they had time on their hands. COVID locked them down. So they were very creative in that. But there's something that's coming up, Mr. Constantine, in the question of the school feeding program. Yes. I was thinking about that. Okay, so for the school feeding program, the government has provided support over the years to the school feeding program. And that's something that will continue. We are hoping that our youngsters could get back to school safely in the coming school year. There has been a lot of training being done within this period now. Certifications and now there's some university courses going on. There's a number of things going on to strengthen the school feeding program. The school feeding program, we've always seen as a market for our farmers because they do use a lot of produce in the school feeding program. And so it's one of the areas that we're providing a lot of support to. Some of that work falls directly on Mr. Jabaziz. But we at corporate planning also gave a lot of support to the school feeding program. Kudos to the Ministry of Education to continue their continued hard work. And also the Ministry of Education has taken a more collaborative team approach. So in a lot of the things that are happening under the school feeding program, now the Ministry of Agriculture has a say. We get a chance to contribute and to share a lot more. And so kudos to the Ministry of Education. Definitely. As we're about to wind down, I, can you tell St. Lucian's again and the farmers out there about the importance of the farmer registration program? All right. The farmer registration program, and I'm sure by now most farmers are quickly aware of its value during COVID-19 and lockdown. And when we had those border controls, those persons who did register were able to use those registration to get across. But even more importantly, than navigating during this time, what we're currently doing is what we call registration. So most persons who go to a field officer right now get the information and they will get an ID card. For persons who receive those ID cards in the last couple of years, who have not done the training, it is only a registration card. During this time, we would like the farmer to go back to their farms and implement certain standards. Adeline mentioned some training a little while ago. Some of these people who are not received that training in pesticide use and safety, good agricultural practices, we went ahead and we did a couple cohorts of training and there is a little, there's some more training coming up with that is concerns. The importance of that registration and later on certification because we have still been struggling with Euro standards as to how we're going to do the audit. It is important for us now to go into those farms. They are certain basic requirement, portable water, pesticide disposal, pellets, the restrooms and so on. Signage and that sort of stuff. We want to go back out there as part of stepping up the whole because what's the point of having a park house as international, up to international standards when the process, keep in mind part of the story for the seven crops is to deal with the process, the value chain, what we call the value chain. And so this certification essentially is looking at the entire process from what the farmer is doing on the holding and all of that and to give the consumer a piece of mind that what they're consuming has gone through a process that is safe, that is fair. And we want our farmers to really work with us without his concern. Now it's a big challenge for a certain ministry because it requires a lot of time in terms of sharing and we also for the required time in terms of the assessment of the farmers. We encourage farmers, if you are serious about this business to connect with your field officer and take the necessary steps to ascertain that you are. As we're about to end, we're very close to ending. Moving forward, post COVID, I'm sure quickly, what was the strategy? The strategy is to continue to assist the farmers. The farmers have demonstrated the ability to produce in normal times and in pandemic times, right? So we will continue to support them and to give them all of the necessary tools that they need, capacity building, inputs, seedlings, whatever they need will help them to get that. So they continue meeting the market needs and to also ensure food security for us. Sell the new entity, the new marketing entity. Sell it in half a minute. In half a minute, well, farmers, if you sell to the new entity, we ensure that you are going to be paid in a timely fashion and there will always be space for you at that new entity. Because I think you'll have a new manager right now. Yes, a new manager. So there's a new structure, the new, well, not new, but restructured staff, if you may, for me, call it that way. Mr. CEO, final words from you? Final words, we've been through a storm and we do not know what storms are ahead. So again, farmers, be reminded that this is hurricane season. Let's do the necessaries. We do not have insurances, so we need to ensure that we take the necessary steps to prepare for it. We've fed very well, exceptionally well, during COVID-19, all things considered, but let us remain vigilant in terms of our scheduling, in terms of our production practices, in terms of pest and disease management and giving consumers a peace of mind that the produce that we are offering them is of a high quality and it is safe for consumers. Do you want to give any kudos to your staff? Well, definitely. I'd like to say thanks to everybody who has been working so diligently on this project, the Taiwanese Technical Mission, of course, the Ministry of Agriculture and all the different departments, such as engineering, marketing, extension, research and communication as well. So we'd like to say thanks to the entire ministry and also to our farming population out there for supporting us as we continue to support them. Thank you. So, Mr. Kamil, thank you very much. Mr. Sibati, the CEO. Of course, Mr. Adlin, thank you very much. And of course, Mr. Konstantin, thank you very much. The team agriculture is looking forward for a successful post-COVID activity. Thank you very much. You've been watching Agriculture on the Move. Thank you for viewing the program and continue to view the program regularly because we have enough information for you. But before I end, I want you to remember our bi-local campaign. We are in conjunction with the Ministry of Commerce in that fight. And we want you to remember, love St. Lucia, say so, no, but our tagline, Eat Fresh, St. Lucia's Best. I'm Philip Sidney. Goodbye. Yes, sir.


Yeah, this is Brett with Summit Automotive in Fond du Lac, Wisconsin. You're new and used Jeep Wrangler headquarters. And today I'm excited to go over the 2021 Jeep Wrangler Rubicon here with you. This is a brand new Jeep that we just got off the truck. It's our second 2021 that we've had on our lot. It is a Rubicon and Granite Crystal is the color. This one has the 3.6 liter Pentastar V6 motor with start-stop capabilities. 285 horsepower, 8-speed automatic transmission, and this one's going to get you 24 miles per gallon on the highway, 20 in the city, and then 21 average. We shoot all of our videos in 1080p so if you have HD capabilities on your computer, tablet, or smartphone device, definitely turn them on right now because it's your best way to check out the styling and looks and color of the vehicle before seeing it in person. And if you'd like to check out all the photos on this Jeep in the upper right-hand part of your screen is a link right to our website, click that and check us out there. This one comes with special 17-inch painted and the outside lip polished aluminum rims and they come with the BF Goodrich All Terrain TA KO2 tires, definitely an all terrain tread pattern on there.  Notice you get the Granite Crystal Jeep and trail rated logo with the red outlines on there and the Wrangler sticker is black there. You get the black and red Rubicon stickers on the Sport Hood. Really good looking. This one has the LED lighting group, which gives you the LED running lights in the fenders, the LED halo lights and the LED headlamps. It also has LED fog lamps and the red tow hooks in the front. Now this one's just got the plastic bumpers. You can get a metal bumper option on these Wranglers, the seven-slotted grille. Also you can get color matched fenders if you'd like on the Jeeps and Rubicons, but this one has the plastic ones.  Notice it tells you which Torx wrench to use to get those door hinges off. We're going to take a look at the original window stickers, so feel free to pause this at any second. I'm not going to go through everything, but just the really important stuff like the 3.6-liter, the eight-speed automatic transmission. This one is Granite Crystal, $245 option. It comes with the leather trim bucket seats, which is a $14.95 option. Cold weather group is $9.95, which gives you the heated steering wheel and remote start. The LED lighting group is a $12.95 option, which I think is definitely worth it. You get the $8.4 and premium audio group, which is an $1,895 option. Without that, you get the navigation system, Sirius XM traveling for five years, Sirius XM Guardian for a year, and Sirius Traffic Plus for five years. That all comes with that $1,895 price tag right there. Safety group, which gives you the ParkSense rear park system, is $8.95, and then the advanced safety group, which gives you forward collision warning, adaptive cruise control, and advanced brake assist. High beam headlamp control is $7.95, eight-speed automatic, and the 3.6 are $1,500 options each. Then the color match hardtop is $23.95. Those rims, like I said, are $9.95, and your total MSRP is $54.195. Now, if you want to get your summit price in the upper right-hand part of your screen is a link to our website, click that. You can see all the rebates and incentives going on this vehicle right now if it's still available. 24 miles per gallon on the highway, 20 city, for an average of 21. Not really much to show on the crash test ratings. They do front crash tests only and rollover, which is four in three stars. Probably because it's technically a convertible. Anyways, we'll go through the rest of the vehicle here. Notice you get the rock rails standard with the Rubicon package. Four-wheel disc brakes on here as well. That color match hardtop, so the back piece and the front pieces are all color matched, of course. The LED tail lamps look really good, and you do get those parking sensors in the rear bumper. The red tow hook, LED license plate light, matching spare tire and rim, and of course your HD backup camera, which we'll check out in just a second. Back here is your case for your front hardtop pieces. I'm just going to set that down for a second here. You can put this back seat up. There's a latch right here, it just folds like that, and then the seat will actually go up like so. Now, you can remove this by pulling this bar down, and then it just kind of rolls out of there. Also take note that you have the factory subwoofer in the floor, door hinge bolts, roof bolts, and windshield bolts. You can store there, and then underneath there are your jack tools. Also take note that all the bars inside of here are color matched. You have three bolts on each side, two on the top for a total of four, to get this back hardtop piece off, and then you have two quick disconnects for your electrical and windshield washer fluid, and they actually store right there, which is really nice. You've got an LED light back here as well. To get this seat back down, you just kind of pull it down like so. You grab this strap right there, and you put it up. Also note that these headrests do go down. You just have to pull this strap right there, which is nice for extra visibility if nobody is riding back here. Put this piece back in here like so. The hardtops work a lot the same the way they used to on the JKs. This glass piece goes up like so, and this swing door is very similar. They made these lighter though, and they actually glide a lot nicer. They changed the hinge right there, so it's a lot smoother when you close these doors. You also get a plate right here for the JL for a two-door, four-door wheel base and overall length, as well as water-forting right there, which is pretty cool. You can see how nice and smooth those back doors now close. You do get the metal field door cover right there as well. On these mirrors, you have the blind spot monitoring, and they are heated and power. Inside those leather-trimmed bucket seats look really good with the red stitching. You also get the red stitching on the Rubicon on the backrest, driver's seat height adjuster. Both these front seats are heated, and then to get to the back, there's a handle right here. It'll fold forward like so, and then it slides like that. Note, you also get side-current airbags. Factory floor mats back here, those seats are trimmed out the same way, and you do get latch-tied safety system for any child car seat you may want to try and put back there. Backing doors, power mirrors, auto headlamps, tilt and telescopic steering wheel. Inside you get the 7-inch LCD display, which gives you the digital speedometer outside temp and compass display. You can change those corners to read pretty much whatever you want. Looks really good. Notice the red dash trim right there, I love that. Also the red stitching on the steering wheel, everything's just really nicely color-coordinated in this car. Cruise controls and information center controls on the left. Cruise controls and adaptive cruise controls on the right. You also get audio controls on the back of the steering wheel. We get the 8.4 touchscreen radio with the 4C radio. This one has, I got the off-road pages up, which is a pretty cool thing I always like to show. It takes a second for them to load, so I'm glad that I got it up here. Has the pitch and roll. You also have your latitude, longitude, and your altitude right there. You get your accessory gauges with your coolant temp, oil temp, trans temp, oil pressure, and battery voltage. And then you also have your drivetrain here, which is pretty cool. You get your steering angle, which you can see as you turn the steering wheel that changes. Whether you got it in two-wheel drive high, four-wheel drive high, four-wheel drive low. You also can tell if your sway bar is connected, front and rear axle if they're locked or unlocked. So really cool stuff there. Also AM, FM, and Sirius XM radio capabilities. You get all that stuff with the Guardian and the Traffic Plus and everything with this radio.  You can do your heated seats right there and your heated steering wheel. And then check out this backup camera. They made them HD, super nice. They're dynamic. They turn with the steering wheel in that centerline lines right up with the middle of the vehicle. So if you put a hitch on there, you can line it right up every time. Also, you've got Projection Manager, Android Auto, Apple CarPlay. You can project your cell phone if you've got a different navigation program you want to use. You can do that pretty easy. Down here, you have more tactile controls. And if you want to check out the demo of that, we did an Android Auto demo on an A4 in the upper right-hand party screen. Click that and check us out there. Down here, you've got your more tactile climate and audio controls. Start, stop, stability control, downhill, assist control. And you can turn that screen off. You've got the front and rear lockers or just the rear lockers, four-wheel drive, sway bar disconnect, 8-speed automatic transmission. You can get an AUGS USB and USB-C. And the front hardtop pieces come off just like the old ones did in the JKs. You also get a home link up there, SOS and assist buttons. If you'd like to see more pictures of this Jeep or one of our other 450 new and used cars, trucks, SUVs, go to summitauto.com. And if you'd like to check out more HD videos, you can go to youtube.com slash summitauto. Remember to like, subscribe, and share on this video and all the videos that you see there. In fact, in a second, you'll see a link to subscribe to our YouTube channel on your left. A link to more Wrangler videos like this one on your right. If you have not been to our website on the bottom link to this vehicle on our website, click those check us out. We look forward to help you with this brand new 2021 Jeep Wrangler Rubicon.


Hello everyone, welcome to the eighth lecture in the course design and engineering of computer systems. In this lecture, we will continue our discussion of operating systems concepts. Specifically, we will be discussing the concepts of threads in this lecture. So, let us get started. So, what are threads? So, we have seen what are processes right and sometimes it may so happen that a process may want to run multiple copies of itself on the same machine. Why? For example, consider something like a web server that is handling requests from multiple clients at the same time. Then it may so happen that one of the web server processes has blocked because the user requested a file and it had to read the file from the disk and it made a blocking system call. In that case, we want another copy of the web server process around to service other requests from other users. Similarly, you may want to have multiple copies of a process to run in parallel on multiple CPU cores, right. One process can only run on one core. If you had multiple copies, you can use the multiple CPU cores efficiently. So, there are many reasons why a process may want to have multiple copies of itself. But if you simply just create multiple processes and run them on the same hardware, then we are wasting memory, right. Every process, the code, data, the memory image of the process unnecessarily multiple copies of those are existing in RAM and they are occupying memory unnecessarily. We want to avoid this, right. So, if you have such a situation where you want to run multiple versions of an application but want to keep only one copy of the code in memory, then a better option to do that is to use what are called threads. So, you can think of threads as nothing but lightweight processes, right. A process can create multiple threads of execution and these multiple threads will run on the same memory image of the process but they will run independently, right. These multiple threads will share the same memory image but they will run independently like separate processes. So, if one of the thread blocks the other can run and these threads can run in parallel on different CPU cores, right. So, therefore, it is useful for a process to have multiple threads. If you do not do anything, if you do not create threads then the default is just a single threaded process but most real life programs and applications are typically multi threaded for these reasons. So, let us understand clearly what is a thread, ok. Multiple threads of a process share the code, all the global static variables and heap, ok. In your memory image, if you look at the memory image of a process, there is the code and there is the compile time data and heap. All of these are common. If you have multiple threads they all share all of these elements of the memory image of a process but these threads will execute independently on the process code. So, one thread could be running some part of the code, another thread could be running at another location in the code, right. Each thread will run independently on the process code. Therefore, each thread will have its own separate CPU context, right. So, for thread 1 the program counter could be pointing to one location and thread 2 the program counter could be pointing to some other location executing a different piece of code, right. So, each threads program counter registers they will all be different because they are all running independently on the same process code. So, as a result because they execute independently they will make function calls independently they will push elements on the stack independently as a result each thread will have its own separate stack. So, the user space tags are different for different threads because each thread runs independently calls functions independently and so on. And inside the operating system a thread also has its own separate data structure which is usually referred to as the thread controlled block or TCP. This is like the PCB but if a thread is blocked its context will be stored in the TCB and so on, right. Information about the thread the context of a thread and other things will be maintained in the PCB. And these TCBs of you know if a process has multiple threads all the TCBs will somehow be connected up with the PCB also because details like the memory image and everything are common, right. So, each thread does not have its own memory image. So, that information you will get from the common PCB. So, the summary that you have to understand is threads share a lot of code and data but they have their own separate stacks because they run independently and they have their own separate CPU context because they run independently. So, how do you create threads in a program? So, there are many libraries available for different programming languages that let you create threads. In Linux a very popular library is what is called P-threads. This stands for 4-6 threads, right. So, this P-threads library allows you to create multiple threads and also provides various functions to deal with these threads. So, we will just give you a very simple example of how P-threads works but you are encouraged to look up the exact syntax of this library online. So, if you look at a simple program, normally a program will just have default one thread of execution, right. There is just one way in which you can go through a program code but if you do something like this P-thread create, this creates a separate thread of execution in your program. So, here is your program code, there is one thread that is running through the program code in a certain order. If you create a separate thread, that separate thread will execute a different part of the program's code. So, if you create a thread t1 over here, this thread is given a start function and this thread t1 starts running the program from this point. It executes this function, it can make other function calls, it can do other things on the memory image. Similarly, a thread t2 is given another start function f2 and this thread t2 starts executing the memory image from here, okay. So, each thread starts at a different location and runs through the program's memory image, runs through the program's code independently. And after they are created, the threads run independently from the parent, okay. And the parent can also wait for the threads to complete. So, you have pthreads also provides an API called join. So, if the parent execution, so the threads are executing in their corresponding functions, the parent can wait for the threads to complete using this function pthread join. This is similar to the wait system call. Though with threads, this is optional, it is not necessary for a parent thread to wait for the threads it has spawned to finish, okay. So, the other thing to understand is that with pthreads, these separate threads that are created are treated as separate entities by the OS scheduler. That is if a process creates two threads, then this main process and the two different threads are scheduled independently by the CPU scheduler. They are treated as almost like separate processes that can run independently on the CPU scheduler, right. So, these are called kernel level threads. Why? Because the operating system is aware that these threads exist. But not all threading libraries give you this functionality. Some threading libraries will let you create a thread but the OS is not aware of it. And all these threads are scheduled as part of the same process, right. They are not scheduled independently. So, such threads are called user level threads, right. Then why you might ask, why do we even have such threads? There are many reasons for ease of programming and so on that threading libraries may provide you the abstraction of threads, but actually these threads do not run independently on the underlying CPU hardware. But with pthreads, these threads that you create are scheduled independently by the OS scheduler and therefore they are called kernel level threads. So, now let us understand a little bit more about how threads share the memory of a program. So, threads of a program share all the code in the memory image as well as all the global variables, static variables, heap data, right. Except for the data in the stack, everything else is shared between the threads of a program. So, now let us understand when two threads simultaneously concurrently access the same data what happens, right. You might even wonder what will happen they will just access the data, but that is not the case. There are some challenges here. Let us understand that with an example. So, again it is the same program. I am just giving you small example using the pthread API. Here is a program that has created two threads T1 and T2 and both these threads execute the same start function here, right. And what these threads are doing? There is a global counter which is initialized to 0 and each of these threads executes the same function and terminates. And what is this function doing? It is incrementing this counter a thousand times. So, the parent just executes, thread 1 runs this function increments counter thousand times, thread 2 also increments counter thousand times and both these threads as well as the parent process run independently, you know, they can run simultaneously on different core, same core whatever.  Two threads have incremented it thousand times each. But if you write a simple program like this and actually run it, in reality the value will not be 2000 it will be smaller than 2000, okay. So, what is happening here suddenly with threads what is the computer forgotten how to add two numbers? No, that is not the case. In fact, something very tricky is happening here. So, let us understand what are the challenges when two threads simultaneously access a shared data variable. So, now let us take a deep dive into this example, right. Both the threads incremented a counter. They did something like this counter equals counter plus 1. But this is just a C language code. But when this is compiled and actually in the memory image it is in the form of CPU instructions and this line of C code will actually be three different CPU instructions for example, which is you will load this value of the counter from memory you will read it from memory to load it into a register. Then you will increment the register and then you will store back from the register into the counter, right. This is how this line of code is implemented in your compiled executable. Now, when two threads try to run these instructions concurrently, what happens? Here is one possible scenario that can happen. Of course, one thing that can happen is thread one fully runs, increments counter, then thread two runs fully increments the counter, then again thread one runs again thread two runs. If they run exactly one after the other, what will happen? The counter will be incremented once, twice and so on and you will get your value of 2000 that we have seen in the previous slide. But sometimes that may not happen like that. Sometimes if the execution of the thread, so this is the one thread execution, this is the other thread execution, if they overlap like this, something weird will happen. What is happening here? Initially your counter value is 0 and thread one first ran, it loaded this counter into a register, then this register value is incremented. So, now your register has a value of 1 from 0 to 1. At this point, a context which occurred thread one has stopped, all its register values have been saved and now thread two starts, right. You have a concurrent execution. At this point, when thread two starts, what is the counter value? The counter value is still 0 because thread one has not stored it back yet, it has not completed. So, now thread two once again begins with a counter value of 0, stores it in the register, increments the register to value 1 and writes back a counter value of 1 into memory, thread two is complete. Now thread one runs again, it resumes where it left off, remember. So, now once again this register value is 1, it is written into this counter variable 1 and the counter value is once again rewritten to a value of 1. So, what has happened here? Two threads have run, each has run the code to increment a counter, at the end after incrementing a counter, two times the value is still 1. Note that this may not happen all the time, sometimes they will run one after the other and the increment will happen correctly, but sometimes the increment may not happen correctly because of this concurrent execution. So, such incorrect execution of code that happens due to concurrent execution, that is called a race condition, right. The two threads are somehow racing each other and interleaving in their executions. If they run one after the other in an orderly fashion, there is no problem, but when they interleave like this, when they race each other like this, that is when sometimes bad things can happen, that is why it is called a race condition. And this is due to this unfortunate timing of context switches, right, that you do not know where a context switch can happen, it can happen at a very inconvenient location. And note that the user code cannot disable interrupts or context switches and say that I do not want to have a context switch anymore, right. This is not in the control of the user program. So, therefore, this can happen at any point and it can happen with any data structures, not just counters, right. Data structures, shared data structures can be updated incorrectly due to race conditions. So, when can race conditions happen? They can happen anytime we have concurrent execution on shared data. For example, threads in a process that share the memory of the process, that is one place where you can have race conditions. The other common example is when processes go to kernel mode, even single threaded process, when they are in kernel mode and they share OS data structures. So, there is the common OS data structures and two different processes both go to kernel mode, say on different CPUs and they try to access the OS data structures, right. So, the operating system is shared, the kernel mode execution is shared across all the user processes. So, in such cases also, two processes in kernel mode accessing the kernel data structures can result in race conditions. Note that however, if you just have single threaded processes in user mode, they do not share anything. So, therefore, between two different processes you may not have any race conditions. And how do we fix these race conditions? We require a property called mutual exclusion. That is whenever any shared data is being accessed in some parts of the code, concurrent execution should not be permitted, right. We do not want concurrent execution at all. And parts of the program that need this mutual exclusion are called critical sections, right. So, some parts of multi threaded programs, some parts of the OS code, they are called critical sections. Note that of course, not the entire multi threaded program need not be a critical section, right. Sometimes if the two threads are working on different pieces of data, they can run concurrently, they can run in parallel, whatever it does not matter. But only when they are accessing shared data, common data, that is when we need mutual exclusion and such parts of the code that have access to shared data structures, they are called critical sections. And inside a critical section, we need mutual exclusion, we need only one thread at a time or one process at a time accessing these critical sections. So, how do we ensure this? We ensure this using a mechanism called locking, right. So, this is intuitive. So, if you do not want two people to enter a room at the same time, what do you do? You put a lock and the person who enters the room closes the door, locks the door and when that person comes out, the next person can enter, right. That is the simple concept that we all know. Similarly, for threads also, we have a mechanism called locks. So, various threading libraries will provide these locks to you, right. For example, P thread also provides locks. So, locks are nothing but they are just special variables that you know one thread can acquire the lock or you know lock the lock and the thread when it is done can unlock the lock and as long as a thread has the lock, no other thread can execute the critical section. For example, let us see this example of two threads being created T1 and T2 and both these threads run this function. So, now suppose thread T1 starts running this function, it acquires a lock. You have a P thread mutex lock variable that is there and you can you know acquire or lock this lock. So, once thread T1 locks this lock and you know proceeds to the critical section. At this point, if another thread T2 also tries to run the same piece of code, T2 will block here. T2 cannot proceed here because it does not have the lock and once T1 finishes and releases the lock at this point, then T2 can enter, right. After T1 has released the lock, then T2 will be able to acquire the lock and enter the critical section. So, any thread that when entering a critical section, before entering a critical section it will acquire the lock, after the critical section it will release the lock. This kind of programming will ensure mutual exclusion in the critical section and this is a very important thing to keep in mind when running multi-threaded programs or when accessing operating system code in kernel mode and so on. So, how are these locks implemented? We have seen how locks are used, right, before entering a critical section you acquire a lock, after critical section you release a lock, right. But how is this lock implemented? Say by the P thread library, how do you implement the lock? So, this is not easy, this is quite tricky. So, let us see why, right. So, here I have tried to show you a very simple implementation of a lock. What I am doing is I am using a simple Boolean variable to indicate the lock status. If nobody has taken the lock, this Boolean variable is false and a thread that tries to acquire this lock, what it will do is it will check. Is this lock acquired by somebody else is locked? Is this variable true? While it is true, what do you do? This is a busy while loop, it does nothing. You keep going back while, while is it locked, is it locked, is it locked? You keep on checking, you just keep spinning in this while statement doing nothing, you just wait here. And if nobody has this lock, if this is locked is false, nobody has this lock, then there is no need to wait.  Now, you have acquired the lock, you have checked that nobody else has the lock, you have acquired it, you have set it to true and now whichever thread completes this code has the lock with itself. Now, until this thread releases the lock again, sets it to false again, any other thread that starts will basically get stuck here. Any other thread that tries to acquire the lock will keep on waiting here. That is the idea of this simple implementation of a lock using a simple Boolean variable or you can use any other integer or whatever you want. So, this seems to work. For example, this thread T1 is the first thread trying to acquire a lock, it does not spin here because this while returns false, the lock is free. Then it sets the lock to true, it enters the critical section, all good. Now, while it is in the critical section, another thread that comes is just simply spinning here, it is checking, locked is true. So, while true, while true, while true, it is just in this while loop all this time. Once the lock is released, then this thread, this while stops executing, while returns false, the condition returns false. Now, after thread 1 has released the lock, thread 2 has acquired the lock and it enters the critical section. In this way, they are entering the critical section one after the other. So, we are happy. Then why are we calling this an incorrect lock implementation? Because once again, bad things can happen if context which is happening at unfortunate locations, which we have no control over. For example, this thread, look at this sequence of execution, thread T1, first checks that is the lock free, the lock is free, it is the first thread coming in lock is free. At this point, it has decided that the lock is free and the program counter has moved on to the next line. It has decided to acquire the lock, it has moved there. At this point, before it can set this to true, a context which has unfortunately happened, the program counter value saved, all the context is saved and T1 stops execution at this point, T2 runs. Now, T1 has not yet set the lock variable. So, now T2 checks, lock is free, it will set it to true, it will enter the critical section. Now, at a later point of time, T1 resumes execution, the program counter is here, it is going to run this instruction, it will not go back. Why should it go back? Because it executed that while loop already. So, it will resume from here. It will once again set the lock to true, lock the lock, enter the critical section. Now, what has happened? We have two threads both running inside the critical section. We tried to implement a lock, but we did not achieve mutual exclusion, right. So, therefore, it is the same problem. If you understand, it is the same problem as the previous example. We needed locks to avoid these unfortunate context switches, but what if these context switches happen in the implementation of the lock? It is the same problem, right. We are not solving the problem at all here. So, how do we solve this problem? We have some special hardware support in modern systems to solve this problem, right. We need a way to check a variable as well as set its value and do both these steps atomically, that is in one block. I want to check, is the lock free? If it is free, I want to lock it. I want to set it to true. And in between these two steps, I do not want to break. I do not want to check a lock, think it is free, not set it and somebody else then comes and takes the lock, right. I do not want that. So, I want these two instructions to happen atomically. But how do I do that? As I said before, user programs have no control over context switches. A user program cannot say, oh, please do not context switch me out for some time. That is a huge security violation, right. What if a process just says that, suppose there is a way a system called to tell a process that no context switches, then a process can just do that and completely take over the CPU, right. It can just disable all context switches at any point of time. That is a very bad thing. It starves the other processes in the system. It violates isolation. So, we do not want to ever give user programs at control, saying all context switches are disabled for you for some time. So, then how do we solve this problem if a context switch can happen and break this atomicity? The solution is to use what are called hardware atomic instructions. So, these are instructions that do two things at the same time in one CPU instruction itself, ok. So, we have what is called a test and set instruction. In one instruction itself, you can set the value of a variable and you can check its old value, right. And because it is one hardware instruction, one instruction obviously happens atomically. You cannot have a context switch in between a CPU instruction. You can only have context switch between two CPU instructions, but not in the middle of one CPU instruction. So, if you do both these steps in one CPU instruction itself, in what are called atomic instructions, then your problem is solved. So, for example, here is an example of a lock implementation using test and set, right. Instead of directly just writing using C language code to set this lock variable, I am using this test and set instruction to set the lock variable to true, right. So, what does test and set return? If you say test and set is locked true, it will write the value of true into this variable and it will return the old value, ok. And if the old value returned is true, what does this mean? This lock was already held by somebody else, locked was true. It is held by somebody else and you simply try to write true value again into it. It means you have not acquired the lock, the lock is with somebody else and you have to wait. So, if test and set of this lock variable, if you try to set it to true and the old value returned is also true, it means you do not have the lock, you will wait. On the other hand, if you set a value of true, but the old value returned is false, that means this variable was false, nobody else had the lock and you have managed to set it to true, that means you have acquired the lock, you own this lock now, the lock was free and you have acquired it and this whole transition checking if it was free or not and acquiring the lock happened in one step. And if test and set, this returns false, it means that the lock is free, you have acquired it and then you can break from this while loop, right. So, this is the code to acquire a lock using a hardware atomic instruction. And as you can see, this is a single CPU instruction. Therefore, there is no way in which you break atomicity here, there is no way where you check the lock to be free and then you forget to set it, you come back later to set it incorrectly, all of that is not going to happen here, you cannot be interrupted. So, all modern threading libraries provide locking primitives and all of these locking primitives are implemented using hardware atomic instructions. So, before CPUs supported such instructions, so this is a complicated instruction, right, this is not your regular load store add kind of a instruction, it is a special complicated CPU instruction. Before CPUs supported these kind of instructions, a lot of work was done on how to write software algorithms that can do locking, but all of those are not very easy to do as we have seen in the previous slide. And therefore, we use today all lock implementations use these hardware atomic instructions. So, now in the previous examples of locks that I have seen, if you do not get a lock, if a thread does not acquire a lock, what does it do? It simply keeps spinning in a while loop, right. So, while if the lock is not free, you just do nothing, you keep spinning, right. So, such lock implementations are called spin locks, that is if T1 has acquired the lock, T2 also calls the acquire function, it will keep on busily spinning while, while, while, while, right. It will keep on checking this condition in a while loop. And this is a spin lock, but you can see that this is not very efficient, right. Why is this thread even running when the lock is not free? Why is it wasting CPU cycles for a long time? So, a better implementation can be a thread that realizes that the lock is not free, can just go to sleep, can be blocked, okay. And when the lock becomes free, it can run again, right. Its context can be saved and it can restart. So, such implementations are also possible for locks. Such locks are called mutexes or sleeping mutexes, right. You can either have a spin lock or you can have a sleeping mutex. So, whenever you use any threading library and there is a lock API provided, you can check in the description of the library. Does it implement it as a spin lock or does it implement it as a sleeping mutex? And both these are valid implementations, right. If a thread T1 has a lock, the thread T2 can either busily spin or go to sleep, whatever it is. Both these are correct implementations of mutual exclusion, but they just differ in terms of efficiency. And there are cases where both can be used. For example, if T1 will hold the lock only for a very short period of time, then T2 can just wait busily spin and then get the lock, right. The spin lock is useful. But on the other hand, if T1 will hold the lock for a very long time, then it is better for T2 to go to sleep, be blocked, let some other process run on the CPU and come back again later. So, it depends on your application, how long your critical sections are. Based on that, you can choose either a spin lock or a sleeping mutex for your locking variables. So, there are some guidelines for using locks, which is as we have seen the reasons before. Whenever you write multi-threaded programs with shared data structures and critical sections, you must follow locking discipline. Every shared data structure will be protect, should be protected by a lock, right. And it is up to you, the programmer to ensure that you acquire the lock before access and release the lock after access. And these locks can be coarse grained or fine grained. What does this mean? Suppose you have a big array, right. You can protect this whole array by one big lock saying, you know, acquire this lock, access any element of the array and then release the lock. You can do that or you can have individual locks for each of these array elements, right. I want to access this array element. So, I will acquire this lock, access this element, release this lock. You can do fine grained locking or coarse grained locking, right. It depends on your underlying software architecture.  But on the other hand, it is inefficient. It does not allow parallel concurrent execution, right. So, there are trade-offs here and this is an aspect of application design that the programmer must think about. And also are locks only for reading or writing. So, it is a good habit to acquire locks both for reading as well as writing data. So, you might say what is the harm in, you know, multiple threads reading the same variable. All of these issues are happening only if you are trying to modify a variable, right. When we are incrementing a counter, a problem is happening. But if I am reading a counter, there is no issue, right. So, two threads can read the counter. Why do I need locks? You need locks because while you are reading, somebody else might be writing. And therefore, you do not know, right. Unless you take a lock, you cannot guarantee that nobody else is also updating the data at the same time. Therefore, it is good practice to take a lock whether for reading or writing shared data. But if you think taking a lock for reading is inefficient, a lot of libraries provide separate locks for reading and writing, so if multiple threads just want to read a common variable, they will be allowed. If they say we want a lock only for reading, but if another thread wants to write, then this reading would not be allowed, right. So, you have threading libraries that provide separate locks for reading as well as writing. And if you are using any other third party libraries, implementations of other data structures in your multithreaded programs, you should also check that all those other libraries are thread safe. That is, if you are, you know, in your program you have locks, but if you use another implementation of say a hash table or a queue or something and inside that library, they are not using locks, then you are still in trouble, right. Your multiple threads will access that shared data and get into trouble. So therefore, whenever you are using a library, you should check if the library is thread safe. That is, if the library's implementation will work correctly when multiple threads access the library concurrently, okay. So, these are all the things to keep in mind as a programmer when you are writing multithreaded programs. So, that is all I have for today's lecture. To summarize, we have studied what are threads and why they are needed for concurrency and parallelism, but using threads is not easy. You have race conditions, you have critical sections that have to be protected by mutual exclusion and locks is a mechanism to do that. We have seen how to use locks as well as how to implement locks and we have studied the concept of hardware atomic instructions which are useful for implementing locks. So, as a simple programming exercise for you, please try to write a simple multithreaded program, right. You have many tutorials available online. The P-threads API is particularly simple and easy to use. Try to write a program that has multiple threads and all of these threads are updating a shared counter like the example we have seen. Try to observe race conditions in practice and try to fix them using locks. This is a small exercise that will give you a hands-on feel for whatever we have studied in today's lecture. Thank you all and we will continue our discussion in the next lecture.