1 00:00:01,010 --> 00:00:05,790 In this lecture, we will look at the basic operating system concepts briefly. 2 00:00:06,460 --> 00:00:09,320 These concepts are used in the entire course. 3 00:00:09,770 --> 00:00:12,680 We will talk about them in detail later in this course. 4 00:00:13,940 --> 00:00:16,520 So the first concept is address space. 5 00:00:17,460 --> 00:00:22,650 Address space is the set of addresses that a process can use to address memory. 6 00:00:23,160 --> 00:00:25,650 We will see what the process is in a moment. 7 00:00:26,250 --> 00:00:29,370 In this course, we focus on 64-bit addresses, 8 00:00:30,440 --> 00:00:36,970 each number references a specific address giving us an address space of two to the power of 64 bytes 9 00:00:37,130 --> 00:00:38,370 which is really large. 10 00:00:39,240 --> 00:00:45,470 Also, note that the system we are talking about is byte addressing which means the smallest addressable unit is byte 11 00:00:45,470 --> 00:00:46,880 . 12 00:00:47,480 --> 00:00:54,730 So each address references a storage location which is a byte long. 13 00:00:54,740 --> 00:01:00,040 Within this address space, we can keep part of it for RAM and part for hard disk and some other devices. 14 00:01:00,770 --> 00:01:04,310 So, the address space is normally larger than the physical memory. 15 00:01:06,670 --> 00:01:14,800 The next concept is process. A process is basically a program in execution. Process contains program instructions, 16 00:01:14,800 --> 00:01:20,890 the data the program needs, heap and stack within the address space. 17 00:01:21,950 --> 00:01:28,460 Each process has its address space which process can read and write. 18 00:01:28,460 --> 00:01:36,080 Process also contains other resource such as registers, a list of open files, etc. So a process is like a container 19 00:01:36,080 --> 00:01:38,950 holding all the information in order to run the program. 20 00:01:39,770 --> 00:01:46,880 Here is an example of memory map when process is running, as you see, it includes program instructions, 21 00:01:46,880 --> 00:01:48,050 data and stack, 22 00:01:49,140 --> 00:01:55,710 typically the address is from 0 to max size which can be defined by the OS. 23 00:01:55,710 --> 00:02:01,800 The operating system kernel resides in memory above the max size. The kernel code, data, etc. 24 00:02:03,880 --> 00:02:09,699 When we have multiple processes running on the computer, what happens is that each process has its own address space 25 00:02:09,699 --> 00:02:10,660 , 26 00:02:11,510 --> 00:02:16,000 the program instructions, data, stack are different among processes. 27 00:02:16,750 --> 00:02:23,840 The memory reference within one process does not affect the address space of other processes. 28 00:02:23,860 --> 00:02:30,880 However, the kernel which resides in the higher part of address space are the same across all the processes 29 00:02:30,880 --> 00:02:31,300 . 30 00:02:31,300 --> 00:02:38,320 The operating system kernel includes the essential information about each process, such as process state, etc. 31 00:02:38,320 --> 00:02:41,790 And user programs are not allowed to access data in kernel space. 32 00:02:42,190 --> 00:02:44,160 This brings us operation mode. 33 00:02:44,920 --> 00:02:46,840 There are two modes of operations, 34 00:02:47,500 --> 00:02:49,170 kernel mode and user mode. 35 00:02:49,840 --> 00:02:53,270 The operating system runs in kernel mode. 36 00:02:53,310 --> 00:03:00,250 In this mode, we can execute all the instructions and access all the hardware. The application programs run in user mode 37 00:03:00,370 --> 00:03:04,300 where they can only execute a subset of the instructions 38 00:03:04,300 --> 00:03:06,790 and they cannot access the data in the kernel space. 39 00:03:08,140 --> 00:03:14,950 When a program wants to access data in kernel or hardware, it calls a special set of functions called system calls. 40 00:03:14,950 --> 00:03:21,860 The system call acts as an interface between user programs and the operating system. 41 00:03:22,480 --> 00:03:27,880 When a program calls a system call, the control is transferred to the operating system. 42 00:03:28,420 --> 00:03:34,030 The operating system will perform the operation the program needs and return to the user program 43 00:03:34,030 --> 00:03:35,100 once it is done.