41
Welcome to SWE2024 System Programming Lab Prof. Euiseong Seo TA – Hyeonsu Lee ([email protected]) TA – Seungmin Oh ([email protected]) Computer System Laboratory Sungkyunkwan University http://csi.skku.edu

Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 2: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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.

Page 3: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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.)

Page 4: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 5: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 6: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 7: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 8: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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.

Page 9: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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!

Page 10: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

10SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Any Questions?

Page 11: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

Coding in Linux

Prof. Euiseong SeoTA – Hyeonsu Lee ([email protected])

TA – Seungmin Oh ([email protected])Computer System Laboratory

Sungkyunkwan Universityhttp://csi.skku.edu

Page 12: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

12SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Contents§ Coding standard

§ Debugging tool

§ Text editor

Page 13: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 14: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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.

Page 15: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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>

Page 16: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 17: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 18: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 19: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 20: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual 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

Page 21: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 22: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

22SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Text editor – Vim (7)

Page 23: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

23SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Text editor – Vim (8)

Page 24: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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.

Page 25: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

Setting Up a Ubuntu VM(or Changing your OS to Ubuntu)

Page 26: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 27: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

27SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Installing VirtualBox (1)§ Go to VirtualBox website

• https://www.virtualbox.org/

§ Download installation binary

Page 28: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

28SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Installing VirtualBox (2)§ Next, Next, Next, Yes, Install, Yes … Finish!

Page 29: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

29SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Installing VirtualBox (3)

Page 30: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

30SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Creating a VM (1)§ Include “linux” into your VM name

Page 31: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

31SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Creating a VM (2)

Page 32: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

32SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Creating a VM (3)

Page 33: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

33SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Creating a VM (4)

Page 34: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

34SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Creating a VM (5)§ Double Click VM, or Click Start button

Page 35: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 36: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

36SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Installing Ubuntu on the VM (2)§ Select “Ubuntu-18.04.3,,,.iso” file.

Page 37: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

37SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Installing Ubuntu on the VM (3)§ Select Korean or English

Page 38: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 39: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

39SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Installing Ubuntu on the VM (5)§ Restart,,, and Finish!

Page 40: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

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

Page 41: Welcome to SWE2024 - SKKUcsi.skku.edu/wp-content/uploads/0_introduction-2.pdf · 2019-09-04 · Text editor –Vim (2) §Vim has 6 modes •Normal mode •Insert mode •Visual mode

41SWE2024: System Programming Lab | Fall 2019 | Euiseong Seo

Any Questions?