Skip to content

Instantly share code, notes, and snippets.

@ccckmit
Last active June 6, 2018 00:45
Show Gist options
  • Save ccckmit/d05b7f78e8ca82fe53a62fa666296d63 to your computer and use it in GitHub Desktop.
Save ccckmit/d05b7f78e8ca82fe53a62fa666296d63 to your computer and use it in GitHub Desktop.
csienqu-teacher:~ csienqu$ docker pull ubuntu:latest
latest: Pulling from library/ubuntu
6b98dfc16071: Pull complete
4001a1209541: Pull complete
6319fc68c576: Pull complete
b24603670dc3: Pull complete
97f170c87c6f: Pull complete
Digest: sha256:d93e92b9e184f69873bfd8570647a4298b070119baad4f65d003c96464d858da
Status: Downloaded newer image for ubuntu:latest
csienqu-teacher:~ csienqu$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 113a43faa138 3 hours ago 81.2MB
<none> <none> c0018dca3b61 41 hours ago 4.43GB
<none> <none> b20e428a79fa 41 hours ago 4.43GB
<none> <none> 110a8f309bc6 41 hours ago 831MB
neold2028/nqu1062-ai-keras latest 3a6c3a5d7577 2 days ago 4.43GB
tensorflow/tensorflow latest e7a53807ee54 5 weeks ago 1.33GB
ubuntu <none> 20c44cd7596f 6 months ago 123MB
csienqu-teacher:~ csienqu$ sudo docker run -t -i ubuntu:latest /bin/bash
Password:
root@9a462756d1d2:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
...
root@9a462756d1d2:~/ccc# vim hello.c
bash: vim: command not found
root@9a462756d1d2:~/ccc# sudo apt-get update
bash: sudo: command not found
root@9a462756d1d2:~/ccc# apt-get update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
...
Get:18 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [2786 B]
Fetched 25.3 MB in 12s (2131 kB/s)
Reading package lists... Done
root@9a462756d1d2:~/ccc# apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
...
root@9a462756d1d2:~/ccc# ls
c
root@9a462756d1d2:~/ccc# cd c
root@9a462756d1d2:~/ccc/c# vim hello.c
root@9a462756d1d2:~/ccc/c# gcc hello.c -o hello
bash: gcc: command not found
root@9a462756d1d2:~/ccc/c# apt-get install gcc
Reading package lists... Done
Building dependency tree
...
root@9a462756d1d2:~/ccc/c# vim hello.c
root@9a462756d1d2:~/ccc/c# gcc hello.c -o hello
root@9a462756d1d2:~/ccc/c# ./hello
hello !
...
root@9a462756d1d2:~/ccc/c# git
bash: git: command not found
root@9a462756d1d2:~/ccc/c# apt-get install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
...
root@9a462756d1d2:~/ccc# git clone https://github.com/cccnqu/sp106b.git
Cloning into 'sp106b'...
remote: Counting objects: 1414, done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 1414 (delta 13), reused 20 (delta 7), pack-reused 1383
Receiving objects: 100% (1414/1414), 4.38 MiB | 1.68 MiB/s, done.
Resolving deltas: 100% (393/393), done.
root@9a462756d1d2:~/ccc# ls
c sp106b wp106a
root@9a462756d1d2:~/ccc# cd sp106b/
root@9a462756d1d2:~/ccc/sp106b# ls
README.md example exercise more package.json project
root@9a462756d1d2:~/ccc/sp106b# cd example/
root@9a462756d1d2:~/ccc/sp106b/example# ls
01-generate 02-lexer 03-parser 04-compiler-exp 05-cpu0 06-assembler-hack 07-vm-hack 08-compiler-hack 09-compiler-rubi 11-os-hackos 13-cpu1 c nand2tetris
root@9a462756d1d2:~/ccc/sp106b/example# cd c
root@9a462756d1d2:~/ccc/sp106b/example/c# ls
01-gcc 02-link 03-make 04-makeLib 10-thread 11-socket 99-safety
root@9a462756d1d2:~/ccc/sp106b/example/c# cd 10-thread/
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ls
README.md deadlock.c georgeMary.c mutex1.c norace.c race.c webserver.c
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# gcc georgeMary.c -o georgeMary
/tmp/ccmJU10q.o: In function `main':
georgeMary.c:(.text+0x78): undefined reference to `pthread_create'
georgeMary.c:(.text+0x95): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# sudo apt-get install libpthread-stubs0-dev
bash: sudo: command not found
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# apt-get install libpthread-stubs0-dev
Reading package lists... Done
...
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# gcc georgeMary.c -lpthread -o georgeMary
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./georgeMary
----------------
Mary
George
----------------
George
^C
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ls
README.md deadlock.c georgeMary georgeMary.c mutex1.c norace.c race.c webserver.c
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# gcc race.c -lpthread -o race
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./race
counter=0
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./race
counter=58930
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./race
counter=0
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./race
counter=0
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./race
counter=57252
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./race
counter=28954
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./race
counter=50031
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# gcc norace.c -lpthread -o norace
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./norace
counter=0
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./norace
counter=0
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./norace
counter=0
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./norace
counter=0
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# gcc deadlock.c -lpthread -o deadlock
root@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# ./deadlock
A lock x
B lock y
^C
...
oot@9a462756d1d2:~/ccc/sp106b/example/c/10-thread# history
1 ls
2 cd root
3 ls
4 mkdir ccc
5 ls
6 cd ccc
7 mkdir c
8 ls
9 vim hello.c
10 sudo apt-get update
11 apt-get update
12 apt-get install vim
13 ls
14 cd c
15 vim hello.c
16 gcc hello.c -o hello
17 apt-get install gcc
18 gcc hello.c -o hello
19 ./hello
20 vim hello.c
21 gcc hello.c -o hello
22 ./hello
23 git
24 apt-get install git
25 git clone https://github.com/cccnqu/wp106a.git
26 ls
27 mv wp106a ../
28 ls
29 cd ..
30 ls
31 cd wp106a/
32 ls
33 cd example/
34 ls
35 cd cd ..
36 cd ..
37 git clone https://github.com/cccnqu/sp106a.git
38 git clone https://github.com/cccnqu/sp106b.git
39 ls
40 cd sp106b/
41 ls
42 cd example/
43 ls
44 cd c
45 ls
46 cd 10-thread/
47 ls
48 gcc georgeMary.c -o georgeMary
49 sudo apt-get install libpthread-stubs0-dev
50 apt-get install libpthread-stubs0-dev
51 gcc georgeMary.c -o georgeMary
52 gcc georgeMary.c -lpthread -o georgeMary
53 ./georgeMary
54 ls
55 gcc race.c -lpthread -o race
56 ./race
57 gcc norace.c -lpthread -o norace
58 ./norace
59 gcc deadlock.c -lpthread -o deadlock
60 ./deadlock
61 history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment