Upload
others
View
8
Download
0
Embed Size (px)
Citation preview
Welcome to SWE2024System Programming Lab
Prof. Euiseong SeoTA – Hyeonsu Lee ([email protected])
TA – Seungmin Oh ([email protected])Computer System Laboratory
Sungkyunkwan Universityhttp://csi.skku.edu
2SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Introduction§ Schedule
• 18:00 – 21:45 (Wednesday)• Lecture room: #21514 (Engineering Building)
§ Announcement & Assignment submission• We will use http://csi.skku.edu/course/swe2024-43/
for this lecture.• We will use Icampus to submit the programming
assignments.
3SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
About TA§ Donggyu Choi / Jongseok Kim
• TA of this class• Computer System Laboratory• Office : 산학협력센터 #85533 (5th floor)• Email : Hyeonsu Lee à [email protected]
Seungmin Oh à [email protected]• We prefer email, don’t send icampus note.• Please add “[SWE2024]” in the title.
(It is difficult to find student’s emails in our mail box.)
4SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Course Outline (1)
Operating System (Kernel)
System Call Interface
CPU MEM I/O DevicesHardware
KernelSpace
UserSpace
cd ls vi wget
5SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Course Outline (2)
§ Why we use Linux?• Used in many scientific and industrial settings• Internet servers and services run on Linux• It’s free!
§ How to use Linux?§ How to make [advanced] programs on Linux?
• We will learn various system calls provided by Linux systems
6SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Course Outline (3)§ Very basic Linux commands
• Shell, text editor, compiler
§ Basic Linux system calls• File I/O, Process management• Inter-Process Communication (IPC)
§ Network programming• Sockets
§ Concurrent programming• Processes, Threads
7SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Reference§ Computer Systems: A Programmer’s Perspective
• Randal E. Bryant and David R. O’Hallaron,Third Edition,Pearson Education Inc.2015.
• http://csapp.cs.cmu.edu
8SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Class Policies (1)§ Grading Policy
• Class attendance (10%)• 3 Programming assignments (15 + 15 + 20 à 50%)• Final Exam (40%)
§ There will be no midterm exam.
9SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Class Policies (2)§ Cheating Policy (Important)
• What is cheating?– Copying another student’s solution (or one from the Internet)
and submitting it as your own– Allowing another student to copy your solution
• What is NOT cheating?– Helping others use systems or tools– Helping others with high-level design issues– Helping others debug their code
• Penalty for cheating:– Severe penalty on the grade and report to dept. chair
• Ask helps to us if you experience any difficulty!
10SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Any Questions?
Coding in Linux
Prof. Euiseong SeoTA – Hyeonsu Lee ([email protected])
TA – Seungmin Oh ([email protected])Computer System Laboratory
Sungkyunkwan Universityhttp://csi.skku.edu
12SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Contents§ Coding standard
§ Debugging tool
§ Text editor
13SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Coding standard (1)§ A rule for writing a source code
§ Pros• Specify a common format
for the source code and comments• Allows developers to easily share code.• Looks better!
§ Cons• It’s bothering
14SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Coding standard (2)§ There are many coding standards§ The most important thing is consistency
§ You can use “Linux kernel coding style”• Korean : https://wiki.kldp.org/wiki.php/LinuxKernelCodingStyle
• English : https://www.kernel.org/doc/Documentation/process/coding-style.rst
§ But, we think 4 spaces is good.
15SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Debugging tool (1)§ Still use “printf”?
• In multithread program?
• You have to compile the source code every time• How about “segmentation fault”?
§ GDB• Debugging tool for GNU project• $ sudo apt-get install gdb• Compiler option ‘-g’ needed• Usage : gdb <Executable File>
16SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Debugging tool (2)§ Commands for GDB
• R : Run program• B [FuncName/FileName:LineNum] : Set breakpoint• P : Print variables• S : Step (Go in to function)• N : Next (Skip function)• C : Continue until gdb meets breakpoint• Bt : Print backtrace of all stack frame
(Use this when segmentation fault occurs)• Q : Quit• H : Help
17SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Text editor – Vim (1)§ Vi & Vim
• Vi is the default editor in all UNIX operating systems • It may be hard to learn, but it is useful• Vi in Linux is usually Vim (Vi Improved)• You can easily install Vim
(maybe there are already installed.)– $ sudo apt-get install vim
18SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Text editor – Vim (2)§ Vim has 6 modes
• Normal mode• Insert mode• Visual mode & select mode• Command-line mode & Ex-mode
§ You can easily change between modes.
Normal mode (default) Insert mode
Command-line mode
For navigation and manipulation of text
For inserting new text.
For entering editor commands
Visual modeFor navigation and manipulation of text selections
19SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Text editor – Vim (3)§ Basic interface
• i, a, o, s : Insert mode• v : Visual mode• h, j, k, l or ( cursor keys ) : Cursor movement• ‘:’ ‘/’ : Command mode• ‘Esc’ : return to normal mode
20SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Text editor – Vim (4)§ Cursor movement in command mode
Up cursork
Down cursorj
Left cursorh
Right cursorl
21SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Text editor – Vim (5)§ Exiting Vim in command-line mode
• To save file– :w (name) – (If the file have been saved, you can omit the name)
• To quit without saving – :q
• To forcefully exit without saving changes– :q!
• To save and exit (recommended)– :wq
22SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Text editor – Vim (7)
23SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Text editor – Vim (8)
24SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Text editor – Vim (9)§ For learning Vim ..
• Vim Adventures (Game)– http://vim-adventures.com/
• Vim Tutorial– http://www.openvim.com/tutorial.html
§ Repeat, repeat, and repeat.
Setting Up a Ubuntu VM(or Changing your OS to Ubuntu)
26SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Steps1. Install VirtualBox on your computer
2. Create a virtual machine (VM)
3. Install Ubuntu on the VM
4. Fun
27SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Installing VirtualBox (1)§ Go to VirtualBox website
• https://www.virtualbox.org/
§ Download installation binary
28SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Installing VirtualBox (2)§ Next, Next, Next, Yes, Install, Yes … Finish!
29SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Installing VirtualBox (3)
30SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Creating a VM (1)§ Include “linux” into your VM name
31SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Creating a VM (2)
32SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Creating a VM (3)
33SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Creating a VM (4)
34SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Creating a VM (5)§ Double Click VM, or Click Start button
35SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Installing Ubuntu on the VM (1)§ Go to
http://www.ubuntu.com/download/desktoporhttp://ftp.daumkakao.com/ubuntu-releases
§ Download a desktop image
36SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Installing Ubuntu on the VM (2)§ Select “Ubuntu-18.04.3,,,.iso” file.
37SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Installing Ubuntu on the VM (3)§ Select Korean or English
38SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Installing Ubuntu on the VM (4)§ Just click install, yes, next, continue§ And fill your name(user) and password
39SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Installing Ubuntu on the VM (5)§ Restart,,, and Finish!
40SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Installing Ubuntu on the VM (6)§ Let’s test your VM.§ Press Ctrl + Alt + T to launch a terminal (shell)§ Type the following commands:
$ sudo apt-get update$ sudo apt-get upgrade
41SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo
Any Questions?