So, we've got 10 minutes to cover a pretty big topic here, legal considerations for data sharing. So I'm going to jump right into it with a quick outline of what we want to cover off in this 10 or so minutes. I'll give you a feel for what personal information is and a bit of basic information around the privacy acts here in Australia that we deal with. Then we're going to dive in just looking at personal information in the context of medical research, which is what we're doing on this webinar. We'll touch on how to de-identify personal information or the proper forms in which you can share information and strip out identifiers. And then we've got a few additional legal recommendations and wrap up. And we'll do questions at the end, at the very end of the webinar, like Kate said. So Amanda and I are going to flip from slide to slide, so she's kicking it off. Thank you, Fimi. So I think the first thing to understand is the notion of personal information. I won't be too long here, as I'm sure most of you have a pretty good understanding of what is or what is not personal information. So personal information is any information or opinion about an individual identified or who is reasonably identifiable. So it includes opinion, not any factual information. It doesn't matter whether the information is true or not, or whether the information is stored in manual or electronic form. Health information and genetic information are a subcategory of personal information, which is considered as sensitive. And therefore, the rules around that information are more strict. Any information which is anonymous or which has been de-identified is not personal information because it is no longer about an identifiable individual or an individual who is reasonably identifiable. So really, one of the key elements is to assess whether someone is reasonably identifiable or not. The answer to this question depends on the circumstances. So there are a few things to take into consideration, which include the nature and amount of information, who will have access to that information, how the information was received, and whether or not it is possible for someone holding the information to identify the person using available resources. The notion of personal information is crucial to understand because Australia has a specific legal framework around the handling of personal information. So as you can see on this slide, there are three layers of protection. So without entering into too much details, we can see that there is a privacy act and the APPs at the Commonwealth level. So this act applies to Commonwealth government entities and most private sector organizations. There are a few exemptions such as the small business exemptions. So any businesses with an annual turnover of less than 3 million are not subject to the act. However, if that business provides a health service and holds health information, then the act will apply. Then at the state and territory level, we also have some privacy legislation for the public sector in those state and territories, including public hospitals and universities. In three states, in Victoria, New South Wales and ACT, we also have specific health privacy legislation, which applies to public and private sector in their relevant jurisdictions. In this presentation, we will only focus on the federal act and the APPs. This is first because the MCRI when we work is subject to the privacy act and also because the other regimes are not too different from the federal legislations. And then the last source of protection, but not the least, includes all the statesmen's warranties representation related to privacy that are made by your organization or your agency to your patients or your clients or any individual. So it includes the privacy policy you may have, the privacy statement, the consent form. So really everything that you say in those documents is legally binding and the individuals whose data is being dealt with can expect that you comply with what you say in these documents. So for instance, if you put in your privacy policy that you will never share your patients' data with anyone else, but then you do, then you could be liable for misrepresentation. So diving into looking at personal information more in the context of some of the research you might be doing, really I think all the privacy legislation, like Amadeen said, we're focusing on the Commonwealth Privacy Act here, but all of them really have at their core this central idea of ensuring that you manage an individual's personal information you're collecting in a really open and transparent way with that person. So a few key things to consider when you're collecting personal information as part of a study is really having a good thing about only collecting health information that you really need for the study and not collecting unnecessary information. Obviously you're all across the fact that you need to have the individual's consent to collect their information and that consent needs to be voluntary, it needs to be informed and there's a thorough process that must be followed there. It needs to be current and a research participant needs to know that they can withdraw their consent at any time, so that needs to be made clear. It needs to be really specific, so I think who, what, why, when, all those things are really good questions to ask and present to an individual who's participating in a research study. So why are you doing this study, for what purpose? Being specific around details like we're working with X number of research collaborators and will be required to share your data with our collaborators in Queensland, for instance, is really important because it's that scope of the consent that really governs how you can use it going forward in the future. Obviously an overarching thing to remember is that you have to respect the individual's rights to know, to access, to correct and to withdraw their consent at any time. And one thing to set up at the beginning of any study is to ensure that you've got good team accountability around the management and security of research data that includes personal information. So that might be setting one key person up in your team to manage access permissions to the data, having a process in place around off-site transfer of information. It's orally key principles that you need to consider before kicking off any study. So once you've got your research data and that may contain personal information, just touch on how you can go about disclosing that. So there's these three sort of subsets of types of data. We've got non-identifiable data, which is information that really doesn't enable identification of an individual, and this really means those personal identifiers need to have been permanently removed. If that's the kind of data you're dealing with and you've collected in that way, stripped out all identifiers and intend to share it, you can share it generally freely. It's not only considered personal information, so the Privacy Act doesn't overlay that. Reidentifiable data is probably the most common form of data you're dealing with, and this is where a code has been linked to a research participants so the personal identifiers have been stripped out, but there's one, hopefully just one person who knows has the master list that would enable re-identification to happen. As long as that master list with the codes is stored separately and not shared along with the re-identifiable data, that subset of data that's had the identifiers temporarily stripped out can in most circumstances be shared. Again, you need to think about who's at the receiving end of it. If they could in any way easily re-identify it, then it's not truly something that's had the important stuff stripped out, but generally that's okay to share as well, and then you've got identifiable data, and that's really where the personal information is still in there. I think we caution you around the need to really share identifiable data, and we always encourage researchers to strip out identifiers wherever they can, but if that's the case and you need to share personal information, it's really important that your consent form covered off on that and you have consent around that, because that's the main situation where you'll be able to do it. So how to de-identify personal information? I'm pretty conscious of the time here, so I'll try to go quickly on that one. So as Phoebe has mentioned, if you don't really need to share personal information, you should only share de-identified data. To assess whether your data is de-identified enough, we depend on their circumstances. Some people consider that it is always impossible to really have de-identified information. I guess if re-identification is hard in terms of resources, if it involves a lot of time and money, if it's highly unlikely to happen because of the nature of the information that you're gonna be sharing and on the type of recipient, then the information would not generally be regarded as personal information. The end has published some very helpful guidelines on how to de-identify data. We put the link on the slide here and we really encourage you to download the guide because this is really helpful. And prior to conclude, some additional tips or recommendation from a legal point of view. So firstly, it's really important to understand what are your systems, what kind of information you have at your organization? Does it include personal information? Why do you have that information for which purposes did you collect that data? Where is it located? Is it internally on your own server or is it externally? Is it in Australia or overseas? So we have a good understanding of how it works at your organization. Then it's important to have and implement some procedures outlining how data must be handled and what steps needs to be undertaken prior to sharing that data to external people. Finally, prior to sharing any data, you should really ensure that you have a good contract or agreement that your legal team has approved and so that contract should cover such issue, sorry, such as liability. It's always good to have kept liability for, for instance, loss of data and some warranties. Ensure that your contractor is obliged to comply with Australian privacy laws. It's good to have some security obligations in line with the sensitivity of the data that will be shared and a process in the event of a data breach. As you might know, there is a mandatory notification regime which will enter into force in February next year. So it's important that the recipient of your data notifies you in case they are victim of a breach so that you can then comply with your obligations towards the privacy commissioner and the affected individuals. So I think this is the end of our presentation. Fabulous. Thank you so much, Phoebe and Omondine. That's a really great overview of the privacy legislation and things that people need to consider.


QuickBooks Desktop 2023 Homepage Overview Let's do it within 2-its, QuickBooks Desktop 2023 Support Accounting Instruction by clicking the link below, giving you a free month membership to all of the content on our website, broken out by category, further broken out by course. This course then organized in a logical, reasonable fashion, making it much more easy to find what you need than can be done on a YouTube page. We also include added resources such as Excel practice problems, PDF files, and more like QuickBooks backup files when applicable. So once again, click the link below for a free month membership to our website and all the content on it. In prior presentations, we downloaded and installed QuickBooks Desktop. We then set up the sample file, which we've located here on the desktop. So I'm going to open that up just so we can see that file. I put that into the data files. So there we have it. There's the actual data file in our analogy to Microsoft Words. This is the actual program similar to Microsoft Word program in our analogy. This would be similar to the Word document it being our data file. We could open up this file by double clicking on it, similar as to what we would do with a Word document possibly. But usually in QuickBooks, we first open up the program. So I'm going to double click on the program and then open up the data file within it. Now, if the data file was the last file I had open, it might open directly to the data file. If not, it might go to this screen showing us the files that we had recently opened. Most of the time, the easiest thing to do is just open the last file, which is right here, which is usually the file that we will be working on, especially if we're only working on one file all the time, our company file. But if for whatever reason it does not show up over here, then we could open it this way. We can go to the open or restore down here, or I can find that same thing by going to the file dropdown, open or restore or here. I'm going to open or restore this time. I'm just going to open not restore because this is not a backup file. It's the actual company file. So I'm going to say next and then I would locate it with our dropdown. So there it is. There's our sample file. I'm just going to open that up and open the sample file here. Here we are in the sample rock castle construction. Just a couple of reminders that they have some custom coloring up here that might look a little bit different than your company file. That's just some customization in the sample file. Also, we increased the size of the icons to make it a little bit easier to see. We did that by going to the windows settings here on the actual computer and we went into the display settings and we increased the scale. So if yours are looking a little bit smaller, you might not want them as large as I have them here. But I'm trying to make them large so that you can see them as clearly as possible in a presentation format. Now, usually it's going to open to the prior things that we had open. So the home page opens by default typically. And then if we had any other forms, they're going to open on the right. This screen on the left is going to give us some options to help us to navigate from. And the screens up top, these dropdowns are going to give us some items that can help us to navigate with. The items in the middle are the things that are going to be displayed where we're usually going to be working with the data input screens and reviewing the reports. So you can imagine this place in the middle being where you're going to have like multiple windows that you might want to be toggling between. And then what you're going to be doing within those windows driven by in part the dropdowns up top and the items on the left hand side. Usually every time I open things up, I want to see the open items, which will help me to toggle between the windows on the right. I want to have that on the left hand side. So we'll go over some of this stuff here later. Usually every time I open this, I'll go to the view dropdown and say, I want to see the open windows. That's just going to be automatic for me going forward. Here's the open windows list where we currently have the homepage and the profit and loss. I'm going to close the profit and loss. And after every presentation, I'm most likely going to close everything up. Or if I don't close everything up when we start each new presentation, I will try to have everything closed up other than the homepage so that we can work with it. Now, noticing this gray area in the middle, you can see that I have this window. So this window I can kind of move around as you can see in other windows programs outside of the system by grabbing the top format of it here. And oftentimes I have these three icons, which are similar to what we see in the windows program. I can close it out. I can maximize the screen. I can minimize it. Now we don't want to get these options confused with the options of the QuickBooks itself. The whole QuickBooks program, which has these options, I can hit this window, for example, and then move the whole QuickBooks program in a similar fashion. I'm going to maximize the QuickBooks program. This is now maximizing within the gray area of the QuickBooks program. So typically you're going to want to maximize this because I'm not going to toggle around between the screens with this. Usually I'm going to use the open windows over here to toggle between the different reports, like say we have different reports open. Now the other thing that will usually open, I'm just going to be kind of routine. We'll talk about reports later, but the two main financial statement reports that are going to be impacted every time we do something are the balance sheet and the profit and loss, otherwise known as the income statement. So usually we're going to go in here and go to the reports dropdown every time they're in the company and financials. We got the profit and loss, the P and L, otherwise known as the income statement, which we'll talk more about later. And there it is. I'll typically change the date range for like a year. So I'm going to say 010124. That's January 1st, 2024. The easiest way to type it in there is like 123124, just like that without any dashes or anything like that. And that's usually the easiest way I hit tab to toggle through. We'll talk more about that later. But there's one of our major financial statements. The other one being the balance sheet reports dropdown company and financial and the balance sheet, which is right here. These are the two major reports. And I'm going to change the date up here, 123124. So we're working in the future as to when I'm making the recording, which is 2022. This is often the case with the sample files. I believe because they want to make the sample files sufficiently into the future so they can last a few years without basically having to update them every year would be the general idea. So now you have the toggling in the open windows on the left hand side. So we could minimize this and toggle this way, right? And then see the different reports. But usually I'd like to maximize everything and then use the open windows to toggle between the balance sheet, the profit and loss and the homepage. So you can see this middle area then is kind of where we're working in the display area. And then when we're trying to toggle around or do something within it, we are going to use the options on the left and the dropdowns up top. Now this homepage is going to be something that's quite useful from a visual perspective, especially when you're first starting out. I still use it even now after I've been working with QuickBooks for a long time for certain things because it just gets you that nice visual of the flow chart. This is the way you kind of want to visualize things in your mind is to have this kind of flow chart in your mind and breaking out what's going to happen within QuickBooks by the flow of activities. The vendor cycle, the customer cycle, the employee cycle. We might call those different things. You might call this like the payment cycle, the bills cycle, the vendor cycle, the accounts payable cycle. You might call this the revenue cycle, the customer cycle or the accounts receivable cycle, the payroll cycle, then down here. But this is a great way to kind of visualize how things are going to be happening. Once you have the activities within the homepage visualized, it might be easier to use the dropdowns up top to find certain areas. So you can go up to the dropdown up top and find many of the same items. This dropdown setup being similar to if you remember way back before like Microsoft Office had the ribbon up top. They had basically these dropdowns, same kind of format here. And this is a pretty easy way to navigate. Once you understand things, you're probably going to use the dropdowns more and more rather than the homepage because you have to toggle to the homepage in order to see the homepage. But again, great tool to have that being the homepage. Within the homepage, we have the major cycles, the vendors, the customers, the employees. We want to be imprinting these cycles in our minds. This is how we want to be visualizing the processes. And then within each of these cycles, we have the major forms, these forms being the tools that are typically used to enter the actual financial transactions that are then used to create the major financial statements and the related reports that being the balance sheet and the profit and loss. So in future presentations, we're going to go through each of these cycles and look at each of these forms within each of these cycles and consider the impact as we enter these forms on the financial statements, the main financial statements being the balance sheet and the profit and loss or the income statement. As we do this, remember that there's terminology differences that we have to keep in mind. If you were to take financial accounting in college, for example, you're going to learn standard financial accounting, double entry accounting terminology. When you move to QuickBooks, we still have that terminology that we're going to be using, but we also have some terminology specific to the software of QuickBooks. So for example, when we start looking at these forms, then the names of these forms are going to could be specific to QuickBooks. The fact that these are going to be forms, when we're thinking about QuickBooks, that means basically a data input form. The forms are going to be the things that actually drive the entering of the transactions. From a financial standpoint, that would be the journal entries, the double entry accounting, which is the impact on the major financial statements, the profit and loss and the balance sheet. We can also just see it clearly here where we have the profit and loss, which standard financial accounting terms in the US usually would be called an income statement. So we have some differences in terms of that terminology. We want to keep that in mind because when we're talking to different people, that becomes important. If you talk to an accountant who has never worked with QuickBooks, they just work in other fields of auditing or something like that, then they might not know the accounting terms within QuickBooks as much. They just know the accounting general accounting terms. And if you talk to bookkeepers, then they're generally going to assume that you know the bookkeeping terminology. And you got to keep those two things straight because it can get a little confusing. We'll try to point those out as we go. So in future presentations, we'll take a look at each of these forms and we'll kind of deconstruct what is happening from these forms into the financial statements as we construct the financial statements. Remembering that the process of bookkeeping is taking financial transactions and entering them into the system to create and build financial statements, balance sheet and income statement or profit and loss, which are constructed from past financial history. That's basically the goal. We do that from a financial accounting standpoint by entering double entry accounting system. That's journal entries. In QuickBooks, the journal entries will be facilitated by the data input forms, which should make the data input easier. That's the point. We want to make the data input as easy as possible so that we can have people doing the data input fairly easily without possibly knowing exactly what is happening from a double entry accounting system point of view. But we want to understand what's happening as best we can with double entry accounting so we can set up the system properly and we can analyze if there's any problems with what is going on and we can basically step in there and fix the process. So that's what we'll go into going forward. Also note that you might be thinking that, hey, why don't I just attach this to the bank account and enter the bank feeds. We will talk about bank feeds in a future presentation. We'll have a whole section in and of itself about bank feeds. And I know that the name of QuickBooks, for example, gives the implication that you can just kind of connect to the banks and everything will be quick. It's QuickBooks. But it's still not going to remedy the fact that you have to have some understanding of the forms. The bank feeds are still going to be utilizing the forms as they do the data input. And you're really going to understand this. You have to basically understand the forms even when using the bank feeds properly. We'll talk more about that in future presentations. But also just realize some companies, it might be a little bit easier to use a bank feed process than other companies. It'll be dependent upon, you know, how complicated or different complications. Do you use inventory? Do you have to track accounts receivable? Do you have to create a cruel type of accounts like accounts receivable, accounts payable? Again, we'll talk more about that in future presentations. The end.


What I eat in a day as a vibrate healing coach while I'm detoxing on all fruit chopped cantaloupe watermelon smoothies and The liver cleanser tea you can find it on my website at whatchelseaeds.com and click on herbal blends


This is Think Tech Hawai'i. Community matters here. Good afternoon, Howard Wigg, Code Green, Think Tech Hawai'i, where there's a will, there's a way, which is why we have today as our guest, Mr. Will Geesey. Geesey, that's right. Geesey, yep, with Awanian. Who is, he has three separate titles at his advanced age. One is somewhere right up there with the Sierra Club. Another is with the Hawai'i Solar Energy Association. And another is with the Inter-Island Solar Supply, which is the solar wholesaler. When the solar installers are ready to do a job, they'll call up Inter-Island Solar Supply. I need this, this, this, and this. They get all ready. They pick up their, they pull by their trucks, pick up the stuff and move on. So it's the solar heart of America. I speak without prejudice because I'm a friend of a colleague, Judd, who founded it. Yes, he did. Yeah, he also helped found the Hawai'i Solar Energy Association that I work with. So welcome, Will. And we are, as the audience is gathering, going to talk about solar energy today. And before we leap into the hot topic of PVs or photovoltaics, here's a lead-off question. Since the photovoltaic rooftop situation is so muddled today, and a lot of solar companies are not doing well at all because of that, why isn't everyone back on the solar water-heating bandwagon? And I'll tell you my personal prejudice. I work for the state government. Our mission is 100% clean electrical energy by 2045. And we have that evening peak demand to deal with, whoops, airpiece problem here. Why not push the heck out of solar water heating during this lull in PV because number one, it's a really easy sell. You get 35% state tax credit, 30% federal tax credit, and I believe it's a $750 rebate from Hawai'i Energy. It's just about free, tremendous payback. And from our standpoint, when families come home around five in the afternoon, they've got a battery waiting for them in the form of 80 gallons of very hot water. Out of all the demand that they put on their homes, there is zero for hot water because they've got all the hot water they need. Therefore, that evening, nasty old evening peak gets shaved. So why not push the heck out of it? Well, that's a good question, right? So I mean, first, I just want to say you make a lot of good points. I think the rebate is actually at $500 for Hawai'i Energy, which is kind of sad, because the rebates themselves or the budget that Hawai'i Energy has been allocated keeps going down every year, which is unfortunate, because I think they do a lot of good work. Because I like to say energy efficiency is the other side of the coin, right? Because you have energy generation, which is kind of the hot topic now. Oh, yeah, I can have a PV system on my house. But the other side of it is efficiency, right? If I lower the load that I have to serve with my generator, the generator itself doesn't have to be as big. So you bring up some good points. I would say that, yeah, the industry right now, as far as PV is going, is definitely in flux. And so why isn't there an uptake in more solar hot water systems in the state? Part of that is, you know, if I could speculate, I think you have seen an increase in some of the permits for solar hot waters in the last couple of years since October. Now, there is another reason you sometimes get tangled up with the PV permits, or certainly these days you get all tangled up with it. The solar water heating permitting process, as I understand it, is completely electronic. If you're not in a flood zone or have no other complications, boom. Yeah, you can get online and just go through this like that, yeah. Yeah, so it's really easy to get those permits, and definitely there's been, although recently, you know, the HSEA and other organizations have had a lot of success with the permitting department as far as PV systems go, especially with energy storage. But until recently, you know, it's been difficult to get those energy storage permits. And so solar hot water, obviously, is a way that you can kind of remedy that, right? By lowering your load. I would say that, you know, there's several companies that the Hawaii Solar Energy Association, who are members of the HSEA, who have kind of gone back to their backbone, right, of solar hot water. But I would say that, too, you know, we've had a solar PV boom, and the companies that started working a lot in solar PV just hadn't ever done solar hot water. Good point. It's a whole different animal, and now you're dealing with all this water business, and you have to have plumbing expertise. I think a plumber has to sign off on the job. Yeah, I mean, you have to have a plumbing license, right? So it's two different licenses, right? You have electrical and you have plumbing.  They probably don't do solar hot, like a national solar company. They probably do do solar hot water. Good point, good point. And so they're just not diversified in that way. But thankfully to those companies, you know, they have the capital to kind of wait it out until the tariff gets better the solar market starts picking up. The unfortunate thing is that a lot of local businesses, smaller ones that just did PV and aren't as diversified anymore, because they can't do solar hot water, they kind of unfortunately had to cut staff, you know, and we've seen a pretty significant amount of companies who've lost a lot of staff. I think our most recent HSE report had, I don't know, maybe 50% of staff losses and the ones that we've surveyed. Yeah, I mean, you know, we say, wow, that's a lot. But I mean, these are people's jobs, you know, that they're losing. And yeah, I'd like, I think there's been a slight uptake in solar hot water. Obviously, solar hot water, like I mentioned, and like my boss, Rick Reed says, it's the backbone of the solar industry. And it doesn't change very much. So it's, it's not like influx, like solar PV is. So I would like to see more companies move that way. The problem is they just have to be diversified in that way. And some of them are just not set up for it. But the ones that are, I think, are pivoting to make that in the meantime. Glad to hear it. That warms the cockles of my heart again from the standpoint of evening peak shaving. Yeah, and you're totally right.  But you have a battery in solar hot water, right? That hot water itself is your battery. And there's no danger of it catching on fire. No, or exploding or anything like that. Yeah. So I mean, you've got the battery right there. And it's, you know, 25, $2,000 to $2,500 after taxes and rebates. And the return on investment on that is, is so great. Why wouldn't you do it? I think, you know, if I had a house, I'd be, I bet I'd definitely be thinking about, you know, the first changes that I would make to my house, solar hot water would be up there for sure. And energy efficiency measures. And then like later, when I, you know, have a little bit more capital, or I'm a little bit better to afford a solar PV system, then I'll build that PV system, but it's going to be smaller, right? Because I've gotten rid of all that love, which is great. Yeah. Back in the old days of pre any of this, right, because that's how far back I go, we would look at the energy use profile of a typical Hawaii home, which number one did not have air conditioning. Number two had the electric resistance water heater. That water heater accounted for 40% of the entire load. It still does. In some houses, 40 to 60%. 60% when you have a lot of people under the roof. So there's a lot of dishes to wash, a lot of clothes to wash, a lot of people taking showers. Yeah. So imagine, I mean, translate that into the amount of money that you're saving every, I mean, it just kind of makes sense. Yeah. Yeah. Yeah. So, I mean, I would encourage solar installers and contractors who are able to do that. I mean, to continue trying to diversify their business, build out solar hot water. And we have, you know, unlike most states in the United States, we have a pretty robust solar hot water contractor installer economy here.  Yep. Why would you buy a solar hot water heater when natural gas is cheap? But here we don't have natural gas, but what we do have is the sun and abundant resource. So why not just use that? And we, on, in the mainland states where it freezes in the winter, you have to have a special anti-freezing provision up there too. Yeah. You do not have that problem. Yeah. Yeah. Yeah. It is possible to do it. I just, my dad actually who lives in Madison, Wisconsin, and sold a solar hot water heater. But yeah, it's a little bit more expensive, right? Because you have to have that kind of freon almost in there to prevent it from freezing. Yeah. Not here. Well, I guess unless, unless you live like on top of a big island or something like that. Okay. Well, I can assure you that on top of the big island, they're the only warm bodies up there, number one, are not so warm because they're astronomers. Yes. Those astronauts that just came out of that. Oh, yeah, yeah, yeah. This morning. Yeah. Anyway. So you mentioned twice the word storage, and we're not talking now about hot water storage. You're talking about another kind of storage. What might that be? Right. So kind of the hot thing right now, obviously, is energy storage in the form of batteries. Mostly, I think probably most popularly, lithium ion, I think the most popular manufacturer obviously is Tesla, but we have many different lithium ion batteries that many different manufacturers like LG Chem, Enphase, Simplify, they all kind of developed a lithium ion battery. And so I think this is kind of, the, the PUC itself in 2015 in October made a decision to end the NEM tariff, the net energy meter in tariff, and replace it with two, right? Customer grid supply, which is essentially NEM at a lesser amount. About half the amount. About, yeah, 15 cents. So NEM was at retail, which I think at the time was 24 cents, I might be wrong. But in the other half of it, was customer self supply, which is essentially you can build a solar system on your house, but you cannot export energy to the grid. And the way that this happens in most residences, because people are at work instead of at home during the day, is they store that energy in a battery and then use it at night. So those batteries, again, again, shaving that peak. Shaving that peak, exactly, right? So we have, you know, the infamous duct curve, right? So we have two peaks, one in the morning and one at night. And the energy storage helps to shave that peak by export, or by basically lowering the load that the house is putting onto the grid, right, by using the battery that it's stored up during the day. And so these batteries are often lithium ion, but they can be other things like lead acid or salt water based batteries. Now let me give you something, a piece of information that maybe you don't even know, and this is extra credit for our viewers here. The, as you know, the battery permitting process at the city is pretty gosh darn slow. I've heard horror tales of up to six months, and you can correct me, but I think the reason is that the permit checkers just don't really understand this new technology, and they know that they're capable of catching fire, and they are very, very, very, very, very, very cautious about this. So here's the new piece of information. We, I'm with, sit on the Hawaii Building Code Council. We pass all the building codes. I'm the energy code guy. I think I know what you're about to get. And there's, we just, the governor just signed into law the 2014 NEC, National Electrical Code, and we're lagging behind that. That's a whole different story, because there is the 2017 National Electrical Code, and the last chapter, which is brand new compared to the previous editions of the code, it deals with the battery storage or electrical storage, and it gives the guidelines on how to, and requirements, and how to safely install and operate a battery. So I'm working with Aki, Aki Marso, and Marso, and she has come to the council and testified, and the fire, deputy fire chief sits on the council, and he likes their idea, and that is to take that last chapter of 2017, and at the county level, tack it on as an amendment. Yeah, so basically how I understand it is that it would reference, you know, anything that has to do with the installation of energy storage as it pertains to the National Electrical Code, it references the most recent code, right? So yeah, I mean, so I was gonna say that, first of all, Aki Marso is great, I think she's doing a really good job reaching out to try and get that stuff done, and actually, she was one of the people, so you're right, we saw an issue at the Department of Planning and Permitting, the industry did, and the issue was that it took forever to get energy storage permits, so oddly, the bottleneck was no longer at HECO, it was at the, at least in Oahu, is at the Planning and Permitting Department, and so, you know, over many months, we got together with DPP folks. DPP, Department of Planning and Permitting. Yes, sorry, I need to define my acronyms. Department of Planning and Permitting folks, and they were nice enough to facilitate, and they continued to do so, facilitate some meetings between industry people like myself, the distributed energy resources council and elemental accelerator, and several other people, and we're working really hard to help them, kind of, you know, basically help them figure out what their issues are with energy storage, how we can assure them that the technology is safe, and how we can better integrate it, you know, into their code and into their processes, and those conversations actually have, in the last few months, we've had a pickup in a lot of permits, especially on the residential side, and I attribute a lot of that work to, you know, myself and those other folks as well, especially Aki, who was kind enough to start those meetings up, so I think, you know, it's moving, you know, as all things in Hawaii, sometimes it's slow to get started, but once it does, I mean, it is getting started. The other thing that we're doing is materials and methods, right, so basically, the DPP has an expedited permitting process for certain materials, well, for certain technologies that are vetted by their staff, right, including solar water heating, right, or commercial heaters, all different kinds of stuff, and so one of the things that the industry did was, like, well, we need to provide the DPP with different materials for different battery storage options and different loadouts for these options so that they can be comfortable with them and make an M&M or materials and methods number that then we can help expedite that process, so they know that their plan checkers, first of all, are not spreading their resources very thin to check a bunch of different things because they can look at a whole set of plans now and say, hey, all these plans, they fall under M&M numbers, so these are good, we know these are good. These other plans, we can be a little bit more, we can focus a little bit in, take a deeper dive and see exactly what's going on and feel comfortable with those too, and as we start going through these permits, I think the DPP folks will get more comfortable as they always do, the fire people will, as well. It just takes a lot of work, and I think one of the things that the industry didn't realize was that we, you know, we needed to help initiate that work, and we've done it, and we've got a good working group going, but yeah, you're right, it took a while, but now it's happening, and I attribute a lot of the success to all the people that worked with this, including the DPP folks. So what a concept, collaboration. Yeah, I mean, yeah, right? The other thing about the code, I mean, I think that people don't realize right now, I think we are in the 2008 NEC code is what the city and county uses. I think you're right, yeah. So, I mean, it's 2017 here, and the DPP knows this, and they're like, we need to update this code immediately, and I think from what I know, we're getting very close to updating that code, and you can be sure, rest assured here, that I'm going to work to push that through and get that code updated. Yeah, the process is that the administration, city administration, proposes the code as a bill to the city council. Right. City council introduces it, and then there's three hearings. Right. So it'll be very useful for people like yourselves and Aki to appear at those three hearings. Well, I will definitely be there as well as Leslie Colbrooks at DERC and Aki as well, and you know, we're working with the DPP folks on this, and I expect a lot of success, and it just makes sense, right? It just makes sense to have an updated code, because it just helps facilitate the build out of renewable energy, which I think is what we all want, because we have this big mandate of 2045 that we need to get to, and there's a lot of different pieces that go into that puzzle, and permitting is one of them. Absolutely, and oh, let's see, before we get into any more of that, we're just getting warmed up here. We need to take a break. Howard Wigg, Think Tech, Hawaii. My guest today is Will DC Solar Energy Association, and two or three other hats back in a moment. This is Think Tech, Hawaii, raising public awareness. Hi, I'm Ethan Allen, host of Likeable Science on Think Tech, Hawaii. Every Friday afternoon at 2 p.m., I hope you'll join me for Likeable Science, where we'll dig into science, dig into the meat of science, dig into the joy and delight of science. We'll discover why science is indeed fun, why science is interesting, why people should care about science, and care about the research that's being done out there. It's all great, it's all entertaining, it's all educational, so I hope you'll join me for Likeable Science. Aloha, my name is Mark Shklav, I'm the host of Think Tech, Hawaii's Law Across the Sea. Law Across the Sea comes on every other Monday at 11 a.m., please join us. I like to bring in guests that talk about all types of things that come across the sea to Hawaii, not just law, love, people, ideas, history, please join us for Law Across the Sea. Aloha. Welcome back, Howard Wigg, Code Green, Think Tech, Hawaii, where there's a will, there's a way, which is why we have Will Geesee, Hawaii Solar Energy Association, and we've been talking about topics that are so exciting we can just barely contain ourselves, but we have better move on to the, what we see in the future for solar, and this regards Hawaiian Electric, and they are now, I've worked for Hawaiian Electric, with Hawaiian Electric for probably as long as you've been on the planet, and they have really, really, really changed now. They say in public we're totally committed to 100% clean energy, and they are walking the talk. Two very important measures that they're talking about, which directly relates to photovoltaic on the roof, is DR Demand Response and TOU Time of Use. Which one would you like to discuss first, and describe for our audience? I think, let's kind of start with Time of Use, because I think that's probably the most relevant, and the reason I say that is because in the current distributed energy resources docket, which has to do with obviously distributed energy in Hawaii and integrating it, we're talking about a smart export tariff, which is kind of a new tariff that will be in addition to customer self-supply, that will be essentially a time of use-based tariff in that you will be allowed to export energy at peak times. Tariff means billing. Yeah, tariff means billing. So you'll be paid for the energy that you produce to the grid at a certain rate, and the smart export tariff is basically you will be paid for energy exports at certain times, which happened to be the peak times that we talked about earlier. So the duck curve in the morning and at night, and then during the day you won't export any energy, much like a CSS system, but you'll be storing that energy in your batteries, which then you'll then export during the peak times or at night. And so this is a time of use-based tariff in a way, because the amount of money that you're being given for that exported energy is going to be a certain amount that's determined by the PUC, but it's only going to be during peak times. And so the other thing about time of use, which I tried, but it didn't work out great for me, was they have a time of use pilot program. Generally in Hawaii, the way time of use is done is it's split into three time periods. There's on-peak, mid-peak, and off-peak. And you get charged three different rates. So normally you would get charged just one flat rate for energy use throughout the day. In time of use scheme, you get charged for different time periods when you use energy. So if I come home at five o'clock, kick off my shoes, turn on the TV, I'm getting charged maybe 25 cents or 30 cents or some very high tariff. But if I am working from home in the middle of the day, in off-peak, when there's a lot of solar energy going on and the generators are not, the utility generators aren't going, I'm getting charged a very small amount for energy during the off-peak time. And so this kind of incentivizes a certain customer behavior or incentivizes a certain behavior by companies to use energy during the off-peak because it's going to save you money on the long run. I think the problem was that especially from the residential side, it's not everybody gets to work from home and a lot of people just want to come home at five o'clock and use energy and turn on the TV and relax and not really think about, hey, how much energy am I using? And last I heard, the TOU tariff pilot program, which had 5,000 possible slots, had only about 2,500. But the nice thing about this is that it kind of sets it up for different things, like especially in the realm of PV, right? For smart export, it sets it up for customer-based renewable energy, which has a time of use based tariff as well. And in the future, obviously things like grid services or you get paid almost to not generate energy or you get paid to produce or you get paid to have a service that you give to the grid that's not just straight energy. So it sets it up for a lot of good things. It's a precedent, right? And so anyway. Yeah, let me just try to accommodate us late people here. So probably the cheapest rate would be in the middle of the day starting about 10 in the morning when the sun gets really shiny and going till 4.30 in the afternoon when the sun begins to set. The PVs right now are producing more energy than when electric can accommodate. They can throttle down their power plants only so far. Right. They throttle them down anymore and just like a car, it's going to stall. Yeah, you have to have a must-run generation. Yeah. And the PV actually produces more than that. So there is a certain wastage here. So you want to use as much energy as you possibly can during that time and they're going to make it cheap for you. Why not put your dishwasher, clothes washer, and dryer on timers so that they go on at 10.30, 11.00. Wouldn't that be an option? I think it's a brilliant idea. Also, if you have a hot water heater that's not solar, you could do this as well. Setting everything on timers, I think, is a very simple, very low-cost way for people to save money, especially if you're on a time of use tariff. If you're on a flat rate, like a retail rate, there's no incentive for you to do that, right? And so one of the hopes is that these time of use tariffs will incentivize this type of behavior, but I think there needs to be a really strong effort by the utility as well as other stakeholders to get the word out that, hey, this tariff exists. You need to use this kind of behavior to do it. I think one of those ways, obviously, grid modernization, having people have more access to their data and their usage data, what's called usage profiles, right, where you're looking on when do I turn things on during the day, how much energy am I using, all different kinds of stuff. I think it all incentivizes this type of behavior, but it's hard, right, for people to change the behavior that they've been doing for, I don't know, 50, 60 years. Yeah, it's just plain old habit. It's hard to change habits. One option that I see is in the little newsletter that Hawaiian Electric sends out with our bills is a chart. Here's, let's see, here's midnight. Your rates are fairly low, and here's 10 o'clock in the morning or whatever. Your rate is way down here, and then comes 4.35 in the afternoon, boom, goes up after 9.30 or so, boom, goes down again. I mean, that's totally visual. Right. And then have clever illustrations. Put on your water heater, dishwasher, whatever, put it on timers and put them on this time. You're getting cheap energy. Come on. Yeah, I think one of the things I'd like to see is, you know, state programs to incentivize this type of behavior through technology, right, because everybody loves data. So if you're looking at, I mean, if you own a house and you have a simple CT monitoring thing that connects to an online portal that looks at your energy usage, now you know, or connect to, like, the Internet of Things, which is kind of a millennial term. You're talking like a millennial here. Not my favorite term, but it is applicable at this point, right, because then all the things would be connected and you could set one time for all of them, right. Theoretically, right, in the future this would be great. If everybody was kind of reactive to the grid's wants and needs, and we were all players, and we all contributed to this, it would be great. And that's something that, you know, I hope as we continue to go into the future and work on all these dockets, you know, power supply improvement plan just got closed, the grid monetization plan, the final plan was filed, DER continues to go, all these different things. I mean, I'm really excited for what the future will bring, and I think it will. Speaking of the future, we have a very, very tiny future in this program left to us, and you know, we didn't even scratch the surface, so let's bring you back into not just the future. I have a whole bunch of other topics. Great. And this is affecting everybody's pocketbooks, so they're going to be just fascinated beyond words. So on that sad note, we must bid fond to do to Will Geesey, Hawaii's Solar Energy Association, and a bunch of other hats, talking about a program that is going to affect each and every one of us in the pocketbook. Howard Wigg, Code Green, see you next time.


All right, good morning everyone. So today we get to talk about the final piece of the puzzle from that Hello World program we saw last lecture. So by the end of, it will take us a full week but we'll finally understand Hello World in its entirety. So our main abstraction this course, everything you'll be dealing with, even if you don't know it yet is something called a process and that is a instance of a running program. So a program or I kind of said it interchangeably an application is just a static definition. So it's that executable file, that L file. And so it's just a static file that contains things like the instructions that make up the program, any data associated with us with it. So for us, it was Hello World in that really small program. If you were writing in C, all your global variables, all of that would be defined in that executable file. You have memory allocations, there are symbols it uses. For example, everyone's been using the C standard library. One of the things that's also in that file is all the functions that you use. So the operating system can go ahead and find where they are. Like for example, print F, everyone's used that in their C Hello World program. So those are the things that make up a program. It's just a static definition. You can think of it as just a file. It just contains all the information you need to actually run the program. And then the kind of mechanic of actually running that program is called a process. So that is a executing program. And what the kernel's job is, which is the kernel is an undisputed part of the operating system. So if I say operating system and kernel, I'll say them interchangeably, but the kernel is definitely part of the operating system and then what's in an operating system gets kind of sketchy. But 100% no one will argue that the kernel is part of the operating system. So the kernel is managing processes which are just running instances of your programs, be it whatever you've written, right? Including all the lab one stuff. So you can think of a process as a combination of all the virtual resources that will be continually building up, but it's kind of what represents everything and what we'll be dealing with. So our easiest abstraction is like the virtual CPU. So the kernel or the operating system would at least need to track all the registers like the program counter and any other active registers. But the program counter is probably the most obvious one. So it also contains a bunch of other information. It contains all the resources it can access. So different memory addresses it can access. And then if you try and access something you're not allowed to access, that is a seg fault that we all know very well by now. Also tracks other things like IO. So files you have open, if you have network resources open, it's all tracked at a process level. So it's keeping track of everything you need to actually execute a program. So every execution runs the same code, right? You can have multiple executions of the same program all running at the same time managed by the kernel, but an execution itself. So the process is running some specific piece of code at any given time. So like the program counter is at a certain spot in the instructions. And if you have two processes running the same program, the program counter can be at different places in each of those programs. And we'll see more of this as we actually learn to create processes. But for now we're just gonna kind of stay fairly high level and try and understand it. So why would you do this? Well, processes are pretty flexible, right? They contain all the information you need to know to actually execute something. Contains loads the program, contains all the information you need to actually execute it. You can, given this, right? You can have multiple executions, like I just said, of the same program. So if your application ran for, I don't know, 20 seconds and you said that was too slow, you could have like changed terminals and then ran it again. So now there's two instances of the same program running, but they're in different processes. So they're at each process is executing a different piece of code at any given time. And that allows you to run multiple copies of a process which you may or may not take advantage of. In this course you will take advantage of it, but so far everyone's pretty much just written a program, compiled it and then ran it once, right? No one's really done multiple processes. Well, unfortunately for you or luckily for you that changes now. So to understand a bit more about the process, if we want to define it a bit more, if you want to talk with other kernel developers and sound like you know what you're talking about, a process control block is just that structure that contains all of that information specific to an execution. So if you want, you can go actually, the great thing about Linux is it's open source, so you can just go read the code if you really want to know what makes up a process. So in the kernel it's called task struct and that link is clickable. If you want to browse it on GitHub, it's just a struct, right? Because the kernel is written in C, but you can see it has like, I forget how many variables it has, it has like hundreds of different variables like keep track of different things you would need to keep track of when you actually execute a program. So some of the things that you will need to know that it needs to keep track of is CPU process state, like what state it's in, which we'll see in a few slides, CPU registers, so at least the program counter, scheduling information, so maybe how long has this program been running? If I don't want to have it monopolizing the CPU, for example, any memory management, which is a later topic in the course, IO status, so anything you have open, like any files or anything like that, and any other type of accounting information just all goes into the process control block that you need to make decisions. Okay, so first I have to get into a side because no one's really used threads. So luckily or unluckily for us, in normal English, doing things in parallel and concurrency mean the same thing because we are sane rational people, but computer scientists and computer engineers, we like to make your life difficult, so parallelism and concurrency are absolutely not the same thing if you are talking to a strange computer person like we all are. So if you take the computer definitions of concurrency and parallelism, concurrency is being able to switch between two or more things and then making progress on them, right? So you want to make progress at multiple things at a time and we'll show an example after. Paralysm is kind of more what the actual English definition means. It means running two or more things at the exact same time which means they are independent, right? And you want to run as fast as possible. So we've been getting more and more CPU cores in our machine and you want to be able to utilize all of them as effectively as you can and you just want as much running in parallel as possible while back in the day, if you only had one CPU core, you just have to run things concurrently to have the illusion that things run in parallel when really only there's one CPU executing instructions at any given time. So let's take this convoluted real life example so you'll have to bear with me a little bit. So let's assume we are all polite individuals and you are sitting at a table for dinner and you have four options of what you can do. You can either eat, you can drink, you can talk or you can gesture with your hands and try and illustrate something. But the kind of weird caveat here that I need to use to demonstrate stuff is you're so hungry that if you start eating, you just won't stop until you finish, right? So you won't be able to switch what you're doing. So given that, what tasks can be done concurrently in parallel? So let's see. Can I drink and gesture in parallel? Hands up if you think I can do those in parallel. Okay, yeah, most of us can do that, right? Because they're two different resources, right? I can use my hands and talk at the same time. Drink is similar, although I have to gesture with one hand so let's assume that it's the same case. What about if I want to eat and drink at the same time? Can I do these in parallel? All right. No, right? I have a mouth. Can I do these concurrently? We have a few hands. Okay, most people think we can do these concurrently. Well, this is kind of this bear with me thing. So we're so hungry we can't stop. So we can't do them concurrently because if you start eating, right? You won't stop until you're done. Well, if you, and then you can't switch, you can't drink. So you can't do them concurrently because you just can't switch between them arbitrarily. Let's see, can you drink and talk in parallel? Hands up. All right, can't drink and talk in parallel good because we're, although some people might be able to do that, but again, we were trying to be polite. All right, can we do these things concurrently? Yeah, so we don't have this weird caveat. So I can drink, put it down, talk, drink some more. I can make progress of these two things, even though I can't do them in parallel. And then the final one is, I think, which one is left? All right, let's just go through them again just to make sure, because generally if you can do things in parallel, you can do them concurrently, but it's kind of a weird thing. So we can't eat or drink and talk at the same time and you can't switch. So you can't do those in parallel because it's the same mouth resource and you can't do them concurrently because if I'm eating, I can't make progress on the other one. And if I'm talking, I can interrupt myself while I'm talking, but I can't make progress on the eating thing. So you're taking these two tasks kind of together. So they're only done concurrently if you can just switch between them. So I can't talk and drink concurrently because if I drink, then all I can do is stop drinking. I can't make progress on the eating unless I just do the entire thing. So I can't switch between them. So yeah, and then eating and gesturing at the same time, but not switching. So I can do them in parallel, but not concurrently. I can drink and talk at the same time, but I can switch. So I can't do them in parallel, but I can do them concurrently. And then for talking and drinking and gesturing, I can do them in parallel and concurrently. I could pick one up and I could stop doing one, make progress to the other if I wanted to, but I could just run them in parallel. So in general, if you can do things in parallel, you can do them concurrently. There might be a really weird situation where you can do things in parallel, but not concurrently, but you probably won't run into that. All right, any questions about the difference between parallelism and concurrency? Because when it comes to threading, this will be a major issue. And this topic is actually the source of many, many bugs in the Linux kernel.   But today we will save you. Yeah, yeah, yeah. Yeah, you can kind of think you have two resources.  Yeah. Okay. So we have to take a, because this is operating system course, we can kind of go back in history a bit. So back in the old days, I get to age myself down and finally feel old. Who here has used DOS? All right, one guy. Know what? Yeah. So DOS back in the day was like one of the first operating systems you could use on your machine. It had like a little floppy disk you put in. That's your operating system. And so that operating system being one of the first ones was something called a unit programming one. So it only ran one process at a time. So you couldn't do anything in parallel and you couldn't do anything concurrently. You just ran one process until it finished and then you could switch and do a different one. So you can't do them in parallel, especially back in the day, right? They only had one CPU and you can't even do it concurrently. I can't switch. I have to wait until my program is done. So, you know, if, yeah. So two, and two people definitely can't use it at the same time. So what we have now is called a multi-programming system. It allows multiple processes and that means that any two processes could run in parallel or concurrently depending on the hardware and the kernel would have to support this. So if you only have one CPU, right? You can't run anything in parallel. If you only have one CPU, you'd have to run everything concurrently. But if you have, you know, eight CPU cores, you can run things in parallel and you can't really get away from the concurrency thing. So on your computer, there's probably hundreds of processes running even if you have a very beefy machine with like 16 cores. Because you have a hundred processes, you can't run them all in parallel. So some are going to have to run concurrently. And, you know, if you are a kernel developer, you need to run as much in parallel as possible to kind of take advantage of the hardware. Otherwise, you're just kind of leaving performance on the table. So this is our process state diagram that you use if you are in the operating system. So this is kind of the life cycle of a process. So first, a process is created and the operating system, you know, loads it into memory. So for that Hello World example, it would have to load that 168 bytes and then it can go ahead and set up, you know, the initial program counter and then it goes into this waiting state which also could be called ready, which basically just means it's ready to run. So we will get into how to create a process in the next lecture, but for now we just kind of need to understand the life cycle of a process. So once in this waiting state or ready state, it is able to run but the kernel has not selected it to run and then the majority of the life of a process is just going to be pinging back and forth between running and waiting.  So there'll be a bunch of processes able to run kind of in this waiting queue. You will pick one, which is the job of the scheduler, which is, you know, another lecture and then you will run it for a unspecified amount of time and then you will put it back to waiting. And then in some cases, while it's running, it might go to this block state, which basically just means it's requesting some resources or like it's reading from a file or something that is slow and it needs to wait to complete to be able to run again. So if, you know, you're running a program, you're requesting a file, right? This has to read it from disk, disks are way slower than CPUs. So it will go into this block state where it can't make any progress anymore until it's actually, the kernel goes ahead and reads that whole file in or whatever it needs to do. And then after it reads the whole file in, it would go back in this waiting state where it can go ahead and run again. And then at some point, it will go from the running state and go to that terminated state. And that's when it would do that system call for exiting or exit group. So the exit group call transitions you from running to terminated and then that process is dead anymore, dead now and it's done. Yeah, or you can think of, yeah, yeah, pretty much. So waiting can just, you can think of a queue of everything that wants to run and then we'll get into how to decide that later. But yeah, so the job of deciding what's to run. So basically take out of that queue is called the scheduler and that decides when to switch and then what to switch. So when you create a process, right, you have to at least load the entire thing in the memory so you can execute it. And then when it's in this waiting state, the scheduler again coming later decides when to put it in the running state. And but first, before we even get into deciding, we'll just go over the quick mechanics of how you even switch what process is running at one particular time. So this is the core scheduling loop that changes processes. And again, we're just gonna look at the mechanics but overall this is what it looks like. So every single kernel, be it Windows, Mac, Linux, whatever we'll have this core loop as part of it, we'll be executing this core loop. So when it decides it wants to switch it will pause that currently running process, right? So it will stop executing and then you have to save it state so you can restore it again later. So at the very least you would have to, you know, store its program counter and any registers that you're going to clobber after that. Then if you're this, then from the scheduler you get whatever the next process is supposed to be running. And then after you, after it selects that process you just have to restore the state because you put it to sleep, you know, before you restored, sorry, you saved it state before so now you have to restore it. So you would load in the new program counter, right? And then you can now let it run and then this would just keep going on and on and on over and over again. So there's kind of two different approaches for knowing when to actually pause a program. So the first one is called cooperative multitasking which essentially means that the processes decide when to give up CPU. So in these types of systems, which you can already kind of guess is a bad idea, is the processes have to use a system call to relinquish the CPU and then the kernel can go ahead and schedule something else. So the obvious disadvantage of this is if you write a program you want to be, you know, run all the time, you just never make that system call until you're done and then you use 100% of the CPU until you're done and one program can just kind of monopolize the system. So that's one thing you can do if you don't want to kind of put in some mechanics to steal the CPU away, you can just let processes decide which might be okay if you control every single process and want, you know, lots of control over it but in general it's a pretty bad idea. So most kernels use something called true multitasking which the operating system retains control and pauses processes and it can do this through something like interrupts that only it can have access to. So if you have true multitasking there's kind of two ways to do it. You can give processes kind of set time slices so just say you give everything like one millisecond, one nanosecond, whatever and then you just constantly, you could round robin between them and you just give them all individual time slices or if you want you can wake up in a dynamic way and give processes more resources depending on what they're doing and have just dynamic time slices for every process and then you have to do something much, much smarter if you are the kernel. So the mechanic of even swapping processes it has a name, it is called context switching. So at minimum, right, we'd have to save all the registers which is also a kind of weird mechanic because you're using the CPU to save the registers on the CPU that it just came from, right? So which seems a bit weird. So can you imagine, you know, you have to write an interrupt routine that tries to maintain the current program counter and then save it state. You know, you would have to do a bit of math to figure out how many instructions you have and then figure out where it came from which would be kind of weird and then you probably clobber a few registers that you actually needed to save to figure that out. So it's kind of a impossible task without some help. So in general, there's some hardware support that will just, you know, you send a instruction that doesn't touch any registers and just saves it to a memory location. So there's gonna be some hardware support for saving state but a context switch is like pure overhead. So it's just being able to swap between two processes. It's not actually doing any useful work that you care about, right? It's just swapping between two user processes while if you're using your computer, you only care about your processes actually running. So it's pure overhead and you wanna make it as fast as possible. So you might not want to save everything and you want to, you know, you can be smart about it and choose what to save and kind of, if you don't need to save it, you don't save it and you might, you'd need to do that in software because it would be conditional. So there's some tricks in the operating system to save as little as possible. So yeah, you wanna minimize it as much as possible. You can imagine if your context switch, you know, took one millisecond and then your time slices was one millisecond, then in that case, you're gonna waste 50% of your CPU time just switching between processes, right?  So there's going to be some trade-off. On the other hand, right? If it took one millisecond, you could be like, fine, I'll make the overhead 1% and I'll let every program, you know, execute for 10 seconds. So my overhead's really small. Well then, yeah. Oh, so overhead is just time wasted doing not useful work, right? Just, yeah, just how much time is wasted doing something that you don't really care about?  So there's some kind of engineering trade-off with how long to run things versus how long your context switches, right?  Okay, so let's go into kind of the meat of this course, right? We are going to be living at that boundary between kernel mode and user mode and that is through system calls. But to this point, you've been using system calls but you never really known about it. And actually making a system call like I crazily did in that Hello World example is rare. You typically don't do it. So instead, there's C wrappers for most system calls but they behave a bit different than the actual system call. So C is actually much nicer than doing the system call so it does some things for you. So it sets this, you can think of it for now as a global variable called error no. If anything bad happens, so you can read what the error is and it will just, you know, there's a header file called error no.h and it will have, you know, tell you what every single error code actually means and there's some utilities we'll see that actually printed out. It will also do some fun things like buffer reads and writes just to reduce the number of system calls because transitioning from kernel mode to user mode is fairly slow. So if you can kind of batch up what would be multiple system calls into a single system call, that's better. So that's one of the things the C APIs will do for you. It also tries to simplify interfaces. Sometimes some of the interfaces are made to be very composable because there's only like 451 of them to interact completely with the kernel.  And in addition, they might add some new features which we will see. So one of the examples of features you can have is there's an equivalent for exit in C, right?  It will give you some niceties. And one of those niceties is you can register functions to run when a program exits with at exit. So here, right, let's start reading at main. You can register a function called finie that will run whenever your program exits. So first thing main does is register that which should run when it exits and all that function does is just print a string that just says it's executing that function. And then it should go ahead print do main and then return. So if this actually works then that return zero from main is essentially an exit, right? We found out it pretty much does the exact same thing. So if I go ahead and run this, if I go ahead and run this, so again, this is in the examples directory. If I run it, I should see do main and do finie, right? So I don't explicitly call that finie function. I just register it to happen when it exits and it goes ahead and happens, right? So any questions about this example? Yeah. I've never seen registering a function before. Is it special in OS system? No, this is just C. You can do it. Yeah. Sorry? Yeah, it's kind of like a callback. So it just registers functions to run whenever the program exits, right? Any more questions about this? Or like, hmm. So anyone, if I do that, anyone want to hazard a guess of what it's going to print now? So hands up if it just prints the exact same thing. Okay, one, two, three. Hands up if it just prints do main now and skips the other one. Okay, all right, well, let's just try it. So if I do that, all right, prints the exact same thing. Wait, did I make? I don't know, I didn't. So yeah, prints the exact same thing, but now I see that the exit actually happened, right? Because I get the one returned here. So no matter where you exit from, it will actually run that function when you exit, no matter how you exit. Yeah, sorry, what file? I just registered it at the beginning of main. All right, any other questions or want me to do something else fun? So this, so that's just what the API describes. There's some space in C that will store all the functions it needs to run when it exits and that function called just adds that to that list. Essentially. So it's part of a nice feature in C that you can just do that, right? Because if I did a system call, it should just acts the program. Yep, two or three of these, like that. All right, so let's see what happens. If I do multiples of these, they print. And they also print, if you go ahead and read the documentation, they print in a specific order. So if I go ahead and say I do, I'll be super clever here and do one, two, three. So if I do that, there's actually, it will, if you read the documentation at ad exit, it will actually specify an order. So whatever order you register these in, it will undo them in the opposite direction. So if I do that, and if I'm correct, it should go Dufini three, two, and then one because that's the opposite order that I registered them in, right? So if I do that, three, two, blank. Okay, and to see that, this is a C nicety. What I could do too, is I can read the man pages for exit group. And the exit group one is actually a system call. So this is one way to make system calls in C, which again is really rare. So if I go ahead and just do a copy paste on the documentation, oops, include syscall.h. And then what is it, it is, so before I exit using the C one, I can use what is it, syscall, sys exit group. So that will just get me the group number and then let's give it a status of two to differentiate it. So yeah, it's input. All right, so if I do that and execute this, who thinks I will see printfini finished at all, right? Who thinks that it'll just print do main? Okay, so if I'm not lying to you, and this is a system call and that nixes the process, then I shouldn't get any of the nice C additional features, so if I run that, I only do do main and I can see that the system call was actually the thing that exited this because I gave it the status code two. So it was definitely from this system call. So I don't get the nice C features if I just use a system call, right? As soon as execution does do main, makes it to the system call, the process is now dead. Yeah, that's what they defined it as. So in general, that's more useful for people. All right, any questions about that? Yeah. What is the system call? So that's the same system call we did when we just had that handwritten program. So it's just an exit group call which just kills the process. Okay, cool, so let's go to another fun example then. All right, so remember we ran strace on our Hello World program and we got that execve thing at the beginning. Well, now we'll learn what that actually does. So that's obviously a system call and what it does is it replaces the current running process with another program and resets the program counter and all the variables to start executing that new program. So it has the following API, it takes a path name. So the full path of the program to load, which if we're on Linux, now we know that that's an elf file and then it will take what you're accustomed to when you're dealing with C in your main. So this is where argv actually gets set. So it takes as the second argument argv which is an array of strings, which of course is an array of characters. So pointer, pointer, pointer, which is great. And it's terminated by a null pointer. Yeah, it's terminated by a null pointer and then part of the thing your kernel would do, you get argc and argv. So your kernel would go ahead and count the number of pointers for you and then nicely give it to you in the number instead of going through the array. In the format of the environment variables is the same thing. Environment variables are just some more data that you can just read whenever without passing them as command line variables. So as you get more into software development, you'll see environment variables getting used more. For now, we can just kind of ignore them. We'll only care about argv. And then this function, it says it only returns an error on failure because if it's successful, it does what it's supposed to do. It replaces the current running process. So the current running process is now, it's not dead, but it's now running something else and then you can never go back to it because it just deleted all the information associated with that one. Well, sorry. It doesn't delete all the information associated with it. It just replaced and overwrote all the information. All right, so let's see that example because this is even more fun. So if we look at execve, so first off, I'm in main. I'm gonna print f, I'm going to become another process because that's what I said what it does. And then I have an array of strings. I'll put ls as the first argument because I want to execute ls and then null. And then for the environment, I'll just put null. And then I have to specify the full path of the binary I want. So it's in user bin ls. And then I pass argv and the environment. And then either this call should be successful and I expect ls to happen instead or it just returns a negative one. Then here I save the error number because part of the C API is it says if there's an error, it will set that number. So I just go ahead and save it here. And then called pr, which will use this message and then print out a human readable version of that error no. And then I return the exec return, which is the error no. So I save the error no here because funnily enough, p error can also have an error which would overwrite the other one. So I want my, I just want this program to return an error code that corresponds to the first error that actually happened. All right. So can anyone guess what happens when I execute this program? Anyone? Yep. Yes, but it should also print the first line too, right? Yeah. So if execv works kind of how I described, it should say I'm going to become another process and then go ahead and do whatever ls does. So there we go. And I have a line printed here, right? So if I was truthful, right? It's either going to be successful here to become another process in which case the process will die when ls dies, right? Because somewhere in ls it's going to call exit or it's going to have an error here, fall through and return this. So this line should never, ever, ever execute because it's either successful, it gets transformed or there's an error and it prints it out. There's no case this is actually dead code where that would ever execute because there's only two options, right? Either it works or it doesn't. So let's see the error case. I can call this bin dc344. If I execute this, I'll go ahead and see the first part of my error message and then it'll say no such file or directory because that just doesn't exist, right? So then it goes ahead and returns, it's associated with the number two. All right, any questions about this? Yeah, it transforms the current running process into ls. Yeah, into whatever program you have here. Yeah, so if this is successful, right? The current running process that's running main is now gone, it got replaced by ls. So now it's, whatever was running main now just got replaced with ls. Yeah, yeah. Or no, yeah. So it just runs, it just does ls to a system, OS system, but it doesn't run the files within the system by ls. So it runs ls, so it should give us the exact same thing as if we type ls, but in this case it's a bit different, right? If I run the two, whoops. I didn't compile it. It's a bit different, right? Then running ls, my ls one has colors, but that's because if I do which ls, oh, it's alias to ls dash dash color. So if I want it to match exactly because it's actually an alias, I could do something like this. I could just add the argument to it when I call execfe. So that's what it looks like. So if I go ahead and execute that, whoops, that's the wrong example. Apparently that's an unrecognized option. Oh, color equals my bad. Yeah, so it still doesn't quite print the color because of it uses environment variables and I don't pass them. But if you wanted to, if I wanted to say I wanted to do ls dash l and print everything in a line, right, I would specify that there. And then it's the same output as if I type ls dash l, right? Except minus the colors because of environment variables. All right, any other questions or weird things we're noticing here? Sorry? Yes, and we will see what, but yeah, we'll see what. So you're right, it's replacing it. So I didn't say get rid of. So there'll be some things left over with whatever was running before. And we'll see how to use that to our advantage later. Yeah, so this is the only way to run a different program. So it's used all the time.  That's the only way to run a different process. So the first thing, so the first thing was exec VE happened and we didn't put that in there. So I guess that's another question that's, who did that? Cause we didn't do that. So what, anyone has a guess of who made this call? Sorry? The compiler is a good guess, but no. So the compiler just made, well in this case, I hand wrote this, but the compiler just makes the executable file, right? It doesn't actually execute anything. See? Sorry? Yeah, someone said bash and in the S trace case, yeah. But yeah, pretty much bash. So whatever you typed into to run that program was responsible for running it. So something made that, it was likely your shell. And then the other question is like, huh, well then what process did that replace? Cause that's kind of weird. And that's what we'll see after. So any other questions about exec VE? Cause there's also one weird thing we can notice here. Yeah. Yeah, so not only can you run any program with exec VE, this is the system call to run programs. This is the only way to run programs. Yeah, yeah, in C, right? If you can access a system call, you can run other programs. So in Python, right? They have like sub process, was it the sub process package that will make this a bit nicer for you? But under the hood it's going to call exec VE. Cause this is the only way, at least on Mac OS or Linux to run a different program. All right, anyone see, yeah. Oh, it just means I'm not passing any environment. Like for now I'm just ignoring it, I'm just setting it to nothing. Yeah, it's usually has a lot of stuff. So if you want to see what's usually in there, you can just type ENV on your terminal and it'll show you what's usually there. So it's, yeah. All right, anything, did anyone notice like some weird duplication here? How many times do I have LS? Twice, right? And it's kind of weird that it's just been LS and then my first argument's LS, right? Which is kind of just a convention. So anyone want to guess what happens if I just do that? So will LS work now? Who thinks LS still works? Who thinks LS just breaks because I'm not actually running LS? All right, well, let's try it. Whoops, make. So LS just still runs, whoops. Go away. So yeah, LS still runs. So there's just a convention that the first argument here is the name of the program. Your program might never use it, right? Who here, whenever their parsing command line arguments has ever done anything from the zeroth argument? Does anyone ever use that? No, everyone just ignores it, right? It's just a convention. It's set to the name of your program. You don't really care about it. If you want it to be clever, so one of the programs that implements like CP and RM, like all of those little command line utilities is actually just one binary that changes what it does based off the first argument. But in general, you just never use it and it's just a weird convention. In fact, I could probably just ignore it, right?  Why, I don't need to give you any arguments whatsoever. So if I go ahead and execute this now, which actually, well, let's just execute it. So if we execute that, this is actually a brand new thing that just happened to the kernel. It says, no, you can't do that. So a year ago, if you did this, it would happily let you do that. It happened that no one really thought of that before. No one thought people would be crazy enough just to do system calls with just null as everything. So one of the security executables that controls essentially pseudo who has access to what, never checked that the first argument was null and you could overrun its buffer and then you could escalate your privilege and get root. So this is why you're not allowed to do it anymore because someone didn't realize that you could have zero command line arguments come on and they just kind of rolled with it. So that's a fun new change that you can do, but so now it won't let you do that and you have to kind of follow the convention or just put garbage at the first argument. All right, any other questions? Yeah. So you define you as? Yeah, so that's just where that executable lives. So if you do, if you go ahead and do like which, I don't know who, whoops, which who, it will tell you generally where that executable is. All right, so let's quickly wrap up then. So that's the job of the operating system. Its job is to create and run processes. We don't know how to create them yet, but we know how to transform, which is part of running processes. So at minimum it has to load the program into memory, create a process with context that we will learn how to do. Next lecture has to maintain those process control blocks, including all the state registers, open files, things like that, then switch between running processes using the mechanic called a context switch. And then we saw how to replace programs with other processes using that exact VE, which is the only way to do it in Unix. And we'll kind of see how to compose things and figure out how our shell actually works. So just remember, I'm pulling for you, we're on this together.


In the double displacement reaction of silver nitrate and sodium chloride, we have a solution of silver nitrate, which is carlos. We will add a solution of sodium chloride, which is also carlos. When the sodium chloride solution is added to the silver nitrate solution, a white precipitate in soluble silver chloride is formed.