Berkley CS162 operating system first lesson text version – course introduction

Time:2022-11-24

Cooked meat video address:

The first class is mostly an introduction to the course and an introduction to what an operating system is and why it’s important. One of the greatest inventions of modern times is the Internet, which connects devices of all sizes all over the world through a unified network:
Berkley CS162 operating system first lesson text version - course introduction

The Internet has grown rapidly, like the original ARPANET, which couldn’t handle more than 256 devices, probably around the beginning of the 90’s when the World Wide Web started to develop, and the Internet suddenly became something that a lot of people could use, and now we have about 45 billion devices, covering 60% of the world’s population. Another interesting thing is that there is also a diversity of devices in this picture:
Berkley CS162 operating system first lesson text version - course introduction

Let’s take a look at Bell’s Law again, which expresses the number of devices a person owns:

Berkley CS162 operating system first lesson text version - course introduction

In the beginning, millions of people used one computer, then as it progressed, now each of you may have hundreds of devices doing work for you, such as modern cars have hundreds of processors, you all have mobile phones, laptops, etc. Wait. It’s interesting that the number of computers per person increases as the size of the computers gets smaller.

How to make so many systems work normally and connect together, we have to consider this time-consuming problem:
Berkley CS162 operating system first lesson text version - course introduction

This picture is also what you can often see. The smaller the size of the storage, the closer it is to the CPU, the faster the access speed, and the larger the size, the farther it is from the CPU, the slower the access speed. Regardless, the operating system has to function properly across these different time-consuming scales for the system to function properly.

Berkley CS162 operating system first lesson text version - course introduction

The operating system is basically the core of all of this, and while you’re making incredible advancements in the underlying technology, it’s going to cause every device to be a little bit different, and each generation of technology will evolve differently, butNo matter how complex the hardware, you have to provide a consistent programming abstraction for the application; at the same time, needManage resource sharing between different applications, the more devices we connect, the more resources we can share. Also, by the last third of the semester, we’re going to start talking about some of these really interesting peer-to-peer systems where we can have huge storage systems that span many devices.

We will learn the key components of an operating system:

  • process
  • threads, concurrency, scheduling, coordination
  • address space
  • protect, isolate, share, secure
  • letter of agreement
  • Persistent Storage, Transactions, Consistency, Elasticity
  • device interface

Berkley CS162 operating system first lesson text version - course introduction

What happens behind the scenes when you want to visit a web page? First, a DNS request will be made to try to find out the IP address of the website, and this request will go to the DNS servers on the network, and they will return useful information, and then use this information to send the actual web page request; after routing through the network, it will might be sent to a data center with a load balancer; an available device would then be selected from several possible devices; it would then likely do a search and retrieve information from the page store, and piece it together into something you could Return after using the page. Once we start thinking about the details of this process, there are many interesting questions, such as how are the DNS servers consistent and why are they so difficult to hack? In fact, in the mid-2000’s, someone hacked into them. And then there’s how do you make sure that packets have enough priority when they come into an operating system that your special response queries are not delayed for a long time, which is a scheduling related issue. Hopefully, by the end of this class, you’ll have enough knowledge of the various parts of the operating system to give you a better understanding of these issues.

Berkley CS162 operating system first lesson text version - course introduction

So what is an operating system? In fact, there is no unified concept in this regard, but we can understand what an operating system is from what the operating system does. The operating system is responsible for:

  • memory management
  • I/O management
  • CPU scheduling
  • communication
  • multitasking or multiprocessor programming

What does the operating system have to do with it? File system? multimedia system? User Interface? And a browser?

Berkley CS162 operating system first lesson text version - course introduction

For the definition of operating system, it is difficult for us to give, an approximate definition is everything that the supplier provides when you order the operating system, but different suppliers provide very different things, it may be running on the computer a program ofkernel(kernel), as the semester progresses, you will learn a lot about the kernel. No one will deny that the kernel is the core of the operating system, but when we try to delve into what an operating system is, you guys have to remember that we are going to talk about what it does and what parts are important, but maybe you will never fully know the end What is the operating system.

Berkley CS162 operating system first lesson text version - course introduction

In fact, the operating system can be understood as a typical software layer, which provides applications with access to hardware resources.Convenient abstraction of complex hardware devices and protected access to shared resourcesandcommunication, and providingsecurity protectionandcertified

Berkley CS162 operating system first lesson text version - course introduction

operating system,What is “operation”?? In the early days, when you made a phone call, they actually had to plug you into the right connection for the wires to connect; then there were early computers, which required computer operators who basically sat in front of these big machines for long periods of time people, make sure it’s working properly, and then you’ll be operating the system. This “operating” system is to ensure that the disk is running correctly, the network is running properly, or the graphics card is running properly.

Berkley CS162 operating system first lesson text version - course introduction

So what constitutes a “system”?? A system is composed of many interrelated parts. Generally speaking, what they cooperate to achieve is much larger than the function of each part itself. Each interrelated part may interact with other parts. Of course, the complexity is also becomes at least the square of n. We have to come up with APIs and other clever techniques to avoid n-squared complexity, because things are already complicated enough. The use and understanding of these APIs issystem programming, system programming is a very important part of this course, and you will be exposed to a lot of system programming in this course.

Berkley CS162 operating system first lesson text version - course introduction

For the hardware/software interface: you have a processor, you have registers in the processor, and these registers point to a part of the memory, so that the program can run; there may be a cache in the processor, but it is not very large, the cache The function is to make memory and disks with large capacity but slow access look as fast as register access, through a certain cache design. In the design of virtual memory, there are also page tables and translation lookaside buffers that can help us. Of course, there are various storages, such as memory and disk. There are also various devices, such as network, display and input, and so on. These complex hardware have their own complex hardware interface, butThe operating system abstracts these complex hardware interfaces into software interfaces for application programs to use. For example, the computing elements of the processor are abstracted, and a bunch of storage devices, such as disks, U disks, and cloud storage, are turned into a single abstraction, that is, a file system, so that applications can be easily used without caring about the contents ( Each bit of data) is actually stored. These are also the core content of this course.

Berkley CS162 operating system first lesson text version - course introduction

The first role played by the operating system ismagiciansuch a role. It will provide simple and clear abstraction of physical resources, it will make you think at least temporarily that you have infinite memory in a way that you have a machine or a processor completely dedicated to you, which has higher level objects like files , users, and messages. This will make it easier for you to write code. For example, if there is no file object, then you are operating a bunch of blocks on disk, and a file is an abstraction of a bunch of individual blocks on disk. They are somehow related to inodes ( inodes) together to form a file.

Berkley CS162 operating system first lesson text version - course introduction
It’s an ordinary physical machine, it has memory, it has I/O, and it may have storage and networking. On top of it we’ll put an operating system, which we’re learning now. The operating system abstracts processor resources into something very neat, namelythread(Thread); we will haveaddress space(Address Space), what we will learn is not a bunch of memory bytes scattered all over the place in DRAM, but a clean address space abstraction, which will allow us to treat memory as if it is completely ours, even with Multiple programs are running. we will havedocument(File), rather than a bunch of individual blocks on disk. we will havesocket(Socket), instead of operating the network card directly. On top of these threads, address spaces, files and sockets, there will beprocess(Process) abstraction, this process abstraction will give us a restricted execution environment provided by the operating system,Run our compiled program in it. To give you a clean environment to program using these abstract resources, there will besystem library(System Libraries)

Why abstracting these intermediate layers is necessary: If you try to remove all intermediate layers and directly operate the bottom layer (sometimes you do this in very special environments), you will find it particularly troublesome, because different bottom hardware interfaces are different. Although these abstractions have a little loss of performance, they bring the convenience of unified interface and unified code.

Berkley CS162 operating system first lesson text version - course introduction
System libraries are linked into your program, then run by a compiler, which is then translated into machine code to run in the program, and then executed in the process environment.

Berkley CS162 operating system first lesson text version - course introduction
What’s in the process:

  • A process has aaddress space, which is a protected memory
  • it has one or morethread, to access those address spaces above
  • other system status(system state): including open files and sockets, etc.

Berkley CS162 operating system first lesson text version - course introduction

Here’s an example, for a MAC system, you can look in Process Monitor or Task Manager. Something like or you execute on a Linux machineps -aux. You will find that there are many, many processes running on your machine. Most are sleeping, but they will wake up at some point to perform some task.

Berkley CS162 operating system first lesson text version - course introduction

This is the operating system’s management of multiple processes, each with its own set of threads, address spaces, files, and sockets, which may run a program with its own linked library, and which actually interact with each other Protect yourself from other processes.The operating system converts the underlying hardware interface into an application program interface, each program has its own process,A process is a protected execution environment

Berkley CS162 operating system first lesson text version - course introduction

Another role of the operating system istrial, the isolation and sharing of resources between management processes.

Let’s look at a simple example next, assuming that in this example onlya processor
Berkley CS162 operating system first lesson text version - course introduction
Suppose we have compiled program 1 (brown) and program 2 (green), we only have one processor (Processor, one core core, we currently think that a processor has only one core, and there may be multi-core ones in subsequent courses situation, not considered here), then how does the operating system make these two programs seem to be running at the same time? First of all, each program has its own process, and each process has its own global uniqueprocess descriptor(Process Identifier). In memory, process 1 has its own memory space (brown), and process 2 also has its own memory space (green). At the same time, there are gray spaces in the memory that represent some memory spaces used by the operating system. Then, what the processor does is to continuously switch processes, starting with one, such as process 1. At this time, the processor executes the code of program 1, and the register area in the processor stores the content needed by program 1. Access is the memory space of process 1.

Then, the clock cycle arrives and a switch is required:
Berkley CS162 operating system first lesson text version - course introduction
At this time, the processor saves the register content of process 1 (this involves the thread control block, which will be discussed later in the course), loads the content needed for process 2 execution into the register to start execution, and then accesses the memory space of process 2.

What happens if process 2 tries to access memory that is not in process 2’s memory space, such as process 1’s memory space? At this time, the Segmentation Fault (core dumped) error will occur, and then the process will be stopped by the operating system.

Berkley CS162 operating system first lesson text version - course introduction

In fact, the operating system provides a protection boundary here. Although these processes are all running on the same hardware, the operating system canPrevent processes from accessing places they should not access, and protect processes from being affected by other processes

Berkley CS162 operating system first lesson text version - course introduction
Finally, the operating system also acts asAdhesiveProvide some essential services, that is, the program will usePublic Service(common service), such as file system service, visual interface service, network service, etc. These public services are usually associated withlibraryclosely linked,You use these libraries to use these services when writing programs

In this way, the content of our first class is basically finished, and you also have a basic understanding and concept of the operating system. Finally, we will mention what makes the operating system exciting and challenging.

Berkley CS162 operating system first lesson text version - course introduction

This is the exciting part of the operating system. The world is a huge distributed system. As shown in the figure, all devices range from large-scale clusters across the world at one end, to small microcomputer system devices and Internet of Things devices and between two all devices in between. That’s why I think the operating system is so exciting, because only a normal operating system can make everything work properly.

Berkley CS162 operating system first lesson text version - course introduction
you sure knowMoore’s Law(This is also proposed by a professor at the University of Berkeley), that is, the number of transistors will double every 1.5 years or so.

Berkley CS162 operating system first lesson text version - course introduction
However, in the early 2000s, this rate slowed down as people foundPutting more and more of these transistors on the chip has run into issues with capacitance and power. In the past, you could wait a few years to get twice the performance of the machine you’re using now, and sometime in the 21st century, that trend came to an abrupt halt. What to do about this? suddenly peopleHad to make multi-core processors, and design massively parallel computations

Berkley CS162 operating system first lesson text version - course introduction

Power density, capacitance, a lot of things are what caused people to suddenly make multi-core, not to make it faster, but the speed did increase. However, Moore’s Law is coming to an end, not officially, but already Unable to maintain the original growth. But that doesn’t mean people aren’t cramming many devices together, connecting them with a network,It just means that the network has become more important, and the cornerstone of the network to work properly is the operating system we learn

Another thing is that the storage capacity keeps growing:

Berkley CS162 operating system first lesson text version - course introduction

so we have more equipmentmore storage space, more devices more storage space more people means greater demand for operating systems, that’s another reason why we have to learn operating systems.

Berkley CS162 operating system first lesson text version - course introduction
However, learning the operating system is a very challenging thing, and the challenge mainly comes from the complexity. The application is composed of many software modules, runs on many devices on many different hardware platforms, and may be subject to malicious attacks to cause failure,It is not feasible to perfect software by testing it under all possible combinations of environments and components, we have to learn how to build these complex systems in a basically feasible way.