CS4414: Schedule of Lectures (Zoom link is on home page)

All lectures will be available in three modes: Online streamed for real-time viewing, recorded for asynchronous viewing, and as a Powerpoint or PDF that you can download for use in making notes or following a streamed lecture.  Because CS4414 is a new course offered for the first time in Fall 2020, some slides may be updated at the last minute.

An important note about the books:  BO  (Bryant and O'Halloren) is used for multiple courses (they explain this in the preface), and hence explores topics not included in CS4414.  Moreover, they use C for examples.  Despite this, we picked the book because we like their coverage of the topics we talk about, and C is a subset of C++, so their examples work in C++ too.  If a section doesn't look like something we talked about in class, just skip that section.  If uncertain, just ask us (for example, on Piazza).  BS (Bjarne Stroustroup) is a fantastic but very focused text specifically on C++.  We don't have a separate Linux book, because all of that material is online.  You will also find the C++ reference website (cppreference.com) useful.

Our broad topic is focused on programming "the system", as distinct from writing a program to solve some single problem.

To tackle this topic, we'll need to understand the system that we are controlling: the system we are programming.  So in particular, although CS 4414 looks closely at Linux, the bash shell and commands you can launch from it, and at C++ 17, this is not actually a class focused on teaching you Linux, bash or C++ -- we will show you aspects of all three, but we expect you to learn these yourself (with our help and with various pointers we provide).  

Lectures 1-7 look at big issues we need to be thinking about: various types of resources (memory, CPU cycles, files...), costs and opportunities they expose, and the many forms of concurrency we see in a modern system, where the operating system might be hard at work, the file system doing various things as well, and where your own code could also be running in multiple processes or using multiple threads.  Running through all of this are some unifying concepts that we will revisit throughout the entire semester.
   1. Sept 3 Introduction pptx pdf We will explore the different kinds of costs seen with standard languages and systems.  BS Chapters 1-3.    I'll show some code examples (including one I wrote that isn't using a very pure C++); you can see the actual code here.  We recommend coding the way Sagar does.
   2. Sept 8 Architecture pptx pdf Modern computers use a NUMA architecture.  What does this mean and why does it matter?  Skim BO Chapters 1-4, but see note above!
   3. Sept 10 Concurency pptx pdf There are many ways to harnass the power of a NUMA machine.  In Linux, people used to refer to this as "multitasking", and we'll look at that idea (for example, running a few Linux commands at the same time).  But we'll also start to touch on ways that we can use parallelism within our own programs.  This will become a big theme for the class that runs through the entire semester.
   4. Sept 15 Linux pptx pdf We'll dive a bit deeper to gain an appreciation of what Linux is doing, and how it can actually be "programmed" through scripts that treat Linux commands as programmable components.  BO Chapter 7 has some useful context, but in fact much of this lecture is focused on Linux commands, and the bash and Linux help documents and user manual are the best sources of details here.  You should definitely read about these, and try them!
   5. Sept 17 Memory pptx pdf Data lives in memory, but in a Linux system, even the basic idea of a memory segment turns out to be a very sophisticated concept.  We'll have a look.  BO Chapter 6, Chapter 9.
   6. Sept 22 Systems abstractions pptx pdf Dijkstra was the first to suggest that an operating system "abstracts" the hardware, and that this concept could be carried forward to create a hierarchy.  We will discuss concepts of modularity at the level of larger components of a system.  BO Chapter 9.
   7. Sept 24 Exceptions pptx pdf Everyone is familiar with "normal" control flow.  What happens when something abnormal occurs?  Interrupts, signals and C++ are all examples of what we call exceptions.  They illustrate Dijkstra's idea of taking seemingly disparate concepts and unifying them through an abstraction that spans their different functionalities.  BO Chapter 8. 
A core concept in systems programming is the idea of taking control of all elements of the system. 

In a modern computing platform like Linux, all sorts of elements are programmable or controllable, but you as the programmer often need to understand the computing features you are trying to control and you often express that control in somewhat "indirect" ways, for example by coding in a particular style (lecture 8, 9), by "reprogramming" the compiler to generate code for your classes that reflects your own logic and intent (lecture 10), or even by introducing extra layers that redefine seemingly straightforward features (lecture 12).  

In the following lectures we work our way up to this realization, but by lecture 11, on Performance analysis, we see the full picture: if you as a developer can properly visualize your full system, you can use Linux tools to confirm or refute your intuition about where time is being spent, and ultimately use this subtle control features of Linux, the hardware, the compiler, the linker, etc.  In fact even the hardware is often programmable!
   8. Sept 29 Hardware Parallelism pptx pdf In modern systems, the key to speed is parallelism.   We obtain concurrency with threads, but the hardware is also capable of true instruction-level parallelism: so-called SIMD computing.  How can we help the compiler find opportunities for SIMD parallelism in a standard program?   Again, the key turns out to center on viewing the idea of hardware parallelism as an abstraction -- a conceptual building block.  BO Chapter 5.
   9. Oct 1 Constant Expressions pptx pdf This lecture starts a new unit that dives deeper on sophisticated C++ concepts.  We'll begin with a deeper dive into the C++ concept of constants, which have come up in our previous lectures and especially in lecture 9. Constants and constant expressions are evaluated at compile time, and this ide has been taken exceptionally far by modern C++ compilers, to the point that the language has a whole compile-time sublanguage!  BS Section 1.6.
10. Oct 6 Templates pptx pdf C++ abstract types are a compile-time concept, implemented by templates.  Understanding them is a key step in gaining real proficiency in C++. BS chapter 4, 6-8.
11. Oct 8 Performance pptx pdf Our emphasis has been on achieving the utmost in speed.  Can we measure performance?  How would a developer zero in on the performance-dominating portion of a program?  BO Chapter 5.  BS Chapter 5.

I should probably comment that even though the slides for lecture 11 seem to focus on gprof, the topic really is a higher-level question.  Tools like gprof (and Linux has many of them) are awesome, but they can't even come close to what you need to learn to do at a "visualization" level: trying to visualize how something is executing, and using the insights from doing that to either confirm (or refute) your theories by running one of the tools and seeing if the output matches your expectations.  So the theme of stepping back and controlling the entire system (from lecture 10) becomes a theme of visualizing the whole system and using performance tools to focus in on parts that are surprisingly slow -- that deviate from what you expected.
12. Oct 13 Linking pptx pdf When an application is compiled, the compiler transforms the code into an executable.  How are libraries handled, and what happens at runtime when a program that uses DLLs is actually launched?  This topic straddles the boundaries in an interesting way: It has aspects that relate to the application in C or C++, aspects that relate to Linux, and aspects that introduce a new kind of abstraction, which even creates new "super powers"!  BO Chapter 7.
Our next large module looks at threads and thread-level synchronization.  More broadly, our focus is on multiprocessing: situations in which more than one element of a system cooperate to carry out some task, using a mixture of methods: multiple threads, multiple processes, perhaps multiple computers, perhaps even attached hardware accelerators that are themselves programmable.
13. Oct 15 Threads pptx pdf We've seen threads in a shallow way, but this lecture starts a much deeper unit on thread-level concurrency.  Creating threads, distinction between lightweight threads and threads with a dedicated CPU.  Lambda notation in C++. Taskset command.  BO Chapter 12, BS Chapter 15
14. Oct 20 Synchronization pptx pdf Race conditions, critical sections, mutual exclusion, locking.  BO Chapter 12, BS Chapter 15
15. Oct 22 Monitors pptx pdf The monitor pattern is a powerful tool for structured control of thread-level concurrency.  BO Chapter 12, BS Chapter 15
16. Oct 27 Deadlocks pptx pdf Deadlocks, livelocks, how to prevent them.  How systems that are at risk of deadlock deal with this (abort/rollback/retry).  Priority inversion.  BO Chapter 12, BS Chapter 15
17. Oct 29 Coordination pptx pdf Software design patterns and how this idea can be carried over to coordination patterns in modular applications: Barriers, leader-workers, ordered multicast, all-reduce.  BO Chapter 12, BS Chapter 15
18. Nov 3 Multi-Process Systems pptx pdf Many modern systems are big, created by teams and split into multiple processes that sometimes even run on different computers.  How do the forms of sharing and synchronization we have learned about apply in such settings?  What approaches have emerged as the winners for these big systems?
19. Nov 5 Sockets and TCP pptx pdf In lecture 18, we heard about networking.  This lecture will look at how Linux exposes networking via the sockets API.  TCP and Google GRPC. How a web browser uses these ideas.  These topics aren't covered in the textbook, but you will find a lot of information here and here.
20. Nov 10 Two modern networked file systems pptx pdf In lecture 18, we heard about the idea of accessing a file system remotely over a network.  Today, we'll discuss two modern networked file systems.  Ceph is an "object oriented" file system.  Zookeeper is a file system used as a coordination tool.
21. Nov 12 Prefetching and Caching pptx pdf Why file systems aren't slow.
Our course will be on pause from November 13 until December 1, because we do not have any in-person exams.  Good luck with your exams, and have a wonderful Thanksgiving holiday.  We resume on December 1 for our last few lectures.  The first lectures after we resume focus on the ways that distributed computing (over a computer network) resembles threaded parallelism.  These lectures are just a taste of a big topic covered in follow-on courses you could take in the spring.
--                             Nov 17-24                                                       No class (Thanksgiving)
22. Dec 1 Distributed computing I pptx pdf We talked about networked access to a file system in November.  In these two lectures, we'll talk about the MemCached concept and how modern systems manage really big data sets.
23. Dec 3 Distributed Computing II pptx pdf A glimpse of the future: RDMA networking and how Microsoft used RDMA to accelerate the performance of MemCached.  Transactions on a key-value service.
The final module of the course focuses on security.  Cornell has entire courses on this topic, so we limit ourselves to aspects of security directly tied to the systems programming concepts we've seen in lectures 1-23.
24. Dec 8 Security risks in C++ and Linux pptx pdf We will start by discussing classic ways of attacking applications on Linux systems, often via networking APIs that don't adequately check length limits on incoming objects.  BO Chapter 3, especially 3.10
25. Dec 10 Linux Protection Mechanisms pptx pdf Having seen a form of hacking attack, we'll continue our pivot and look at other security and protection mechanisms.  Access to a resource must be authorized, and the party performing the access must be authenticated.  How Linux handles this.
26. Dec 15 Access control abstractions pptx pdf Access control abstractions and the Linux options we use to actually limit access and control the flow of information within a machine, or between machines.