物联网与嵌入式系统概论-week3- Hardware and Software-Lesson3: Operating Systems

原创 2015年11月18日 00:15:26

This series of articles are the study notes of "An Introduction to Programming the Internet of Things", by Prof. Harris, Department of Computer Science, University of California, Irvine. This article is week 3, Lessen 3: Operating Systems.

3. Lesson 3:Operating Systems

3.1 Lecture 3.1 Operating Systems

In this lesson, this lecture will talk about operating systems a little bit. What an operating system is? Now, they're not always present in IoT devices and infact with the platforms we'll be working on, we'll be working with Arduino and Raspberry Pi. With Arduino you do not have an operating system. It's really too slow to support that. But Raspberry Pi you do, typically. So, we'll talk about the role of an operating system and an embedded system and an IoT device. You may or may not need it. 


3.1.1 Flow chart of a application working on a operation system

There's a user at the top, whose using some application. By application we mean the actual program. So you've compiled the program and that application, that's the application code. Do we know that application code would connect directly to the hardware. So it'd go straight from the application to the hardware. No operating system at all. And the application directly controls the hardware. But in say Raspberry Pi or more complicated IoTdevice, you would have something like what you see here where the user attacks the application. The application code actually may not directly connect to the hardware, it communicates with the operating system. So, it makes calls from the operating system and it's requesting hardware service and then the operating system manages the hardware most directly.

3.1.2 Operation system

(1) Manages other programs

Windows, iOS, Linux, etc

(2) Allow many program to be executed together

One thing about an operating system is that it allows you to have not only one application but many applications. Soyou can run lots of different applications at one time, and the operating system itself manages the hardware.Without an operating system you can only run one programat a time.

(3) Incorporates a nice user interface

A nice user interface so often, now, how nice a user interface really depends on the operating system. If you look at a desktopor a laptop Windows, iOS, Linux, something like that, they will have a very nice user interface. Graphic user interface, GUI, you can double-click on something. Double-click on a file, it'll open it up, that sort of thing. That's a full-on operating system. The operating systems that you find in an IoT device, they're much smaller and stripped back. They're not going to have, not likely to have any graphical user interface or anything like that, but they will have a user interface, a command line.

(4) Needs processing power and memory

And it needs processing power. So one thing about operating systems is that operating system itself is a big program. It's a big program that's running in addition to the actual programs that you want to run on your IoT device. So, it's going to consume clock cycles. There are some clock cycles that are spent doing operating system tasks. Some memory that's spent storing the operating system data. Things like this. So, the operating system itself takes up resources so you have to make a decision whether you need one or not. Because it's going to cost you resources, which means cost you money.

(5) Slows downthe system, makes development easier

It slows down the system because while the processor is working on the operating system, doing executing the operating system code, it can't be executing your actual application. So it slows thing sdown. And so as a result, when you use an operating system, you generally need a faster processor. That's why, if you look at an Arduino which is running at maybe 8MHz, something like that, usually don't support an operating system with that. But if you run Raspberry Pi and you've got like 1Gz, then it's okay to support an operating system, because it has enough clock cycles that you can do that.

3.1.2 Operation system example


3.2 Lecture 3.2 Task Support

3.2.1 Multiple Tasks

  • Assume that one microcontroller is being used
  • At least four different tasks must be performed

(1) send video data: continuous while a useris connected

(2) service motion buttons: whenever button is pressed, may last seconds

(3) detect obstacles: continuous at all times

(4)  auto brake: whenever obstacle is detected, may last second

  • Detect and auto brake cannot occur together
  • 3 tasks may need to occur concurrently

So I just talking about how they can happen together, you get detect and auto brake cannot occur together. So if you detect, then you auto brake. They don't happen together, but everything else can happen concurrently. So in a situation like this, you need to have multiple things running at the same time. Multiple tasks being performed at the sametime. Now you could write a relatively complicated program that does all these things at once and checks. While you're sending video data, it's also checking to see if a button is pressed, it's also checking for collisions and so on. But an operating system makes this easier, because you can write each one of these tasks as a separate task and then let the operating system inter-mix them. You can write one piece of code that just sends video data. Another piece that serves as motion buttons, another that takes obstacles. Another one that does auto brake and then you can give them the operating system and the operating system will make sure that they all run at the same time. You don't have to as a programmer, you can write things separately. You can write the sending video data code separately from the servicing motion button code and the operating system can interweave them for you and that relieves a lot of burden for the programmer. So the main job of an operating system is to support a process or a task abstraction.

3.2.2 Process/Task Support

(1) Main job of an OS is to support the Process (Task)

Abstraction

(2) A processis a instantiation of a program;

It must have access to:

  • The CPU
  • Memory
  • Ther resource: I/O, ADC, timers, network,etc.

(3) OS must manage resources

  • Give processes fair access to the CPU
  • Give processes access to resources

版权声明:本文为博主原创文章,未经博主允许不得转载。

单片机设计、嵌入式系统、物联网三位一体

物联网、云计算不是炒作,是嵌入式系统物联与互联网技术在高级阶段上交叉融合变革时代产物。当物联网热闹过后,必然会进入一个理性时代。深入了解嵌入式系统物联史,有助于厘清物联网、云计算的本质。目前,物联网、...
  • stannee
  • stannee
  • 2013年05月12日 19:25
  • 504

操作系统三个简单的部分(Operating Systems in Three Easy Pieces闲来无聊,翻译的)虚拟化部分-原文编号3对话

2-1关于虚拟化的讨论 教授:到这里,我们到了《操作系统三部分》的第一个部分:虚拟化。 学生:哦?那么尊敬的教授,请问什么是虚拟化? 教授:想象一下我们有一个桃子。 学生:一个桃子?(难以置信) 教...

树莓派3 安装谷歌物联网系统-Android Things

一、必备工具 1、树莓派32、Android Things安装镜像3、Windows 10 IoT 核心版仪表板4、内存卡(推荐8G以上)5、显示器(可通过hdmi转vga线连接到vga显示器)...

嵌入式系统概论-1.1

目标:了解嵌入式系统的特点,分类,发展与应用,熟悉嵌入式系统的逻辑组成。 1.嵌入式系统特点 (1)专用性 (2)隐蔽性 (3)资源受限 (4)高可靠性 (5)实时性 (6)软件固化 ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:物联网与嵌入式系统概论-week3- Hardware and Software-Lesson3: Operating Systems
举报原因:
原因补充:

(最多只允许输入30个字)