Week 1 Discussion - The World of Operating Systems

  • Question

Name (and post here as a reply to this topic) a few operating systems that you worked on (had contact with).

Describe your experience and answer comparative questions like:

  • Which one was the oldest?
  • What about the oddest?
  • Which one was more fun?
  • etc.
  • Answer

My first operating system using was Windows 2000 on my father's PC when I was in elementary school. Since I became interested in it, he bought me a PC with Windows XP. After I entered college, I purchased an iBook with Mac OS 10.4 Tiger because Mac OS was designated by my department. Currently, I am privately using MacBook with Mac OS 10.6 Snow Leopard. In my work, I have used Windows XP/Vista/7 and Mac OS 10.5 Leopard. I also have some experience with CentOS 5.x and 6.x as server operations sytems.

I think Mac OS X is a great operating system. Not only its pre-installed applications are functional and sophisticated, but command-line interface is very strong because it is FreeBSD based. In addition, I can run Windows on my Mac with VMware Fusion if needed.

The oddest and worst operating system I have used before is Windows Vista. There are few good free apps for it, and that was extremely slow especially when it booted up.

Homework 1

  • Question

1. Solve Exercise 1.30 from the textbook, page 45. [5 points]

"Define the essential properties of the following types of operating systems:

a. Batch
b. Interactive
c. Time sharing
d. Real time
e. Network
f. Parallel
g. Distributed
h. Clustered
i. Handheld"

2. Using the information from module 1, (especially the commentary), please fill in the blanks in the following sentences:
[3 points = 0.3 * 10]

1. The hardware (the physical devices) is the ________ of the computer system, while the software is the ________ of the computer system.
2. The operating system is a piece of _________ that makes it possible for us to use a computer system.
3. The key word that applies to the operating system from the virtual-machine perspective is ____________.
4. The key word that applies to the operating system from the resource-manager perspective is _____________.
5. There are _________ generations of operating systems.
6. The hardware technology used for the computers of the third generation period was based on __________________.
7. A ___________ operating system allows users to be aware of the existence of multiple computers connected through a computer network, and shares resources across the network.
8. A ___________ is a program in execution, usually consisting of executable code (instructions), data, a stack, CPU register values, and other resources.
9. Modern operating systems allow a process to create (or _______) other processes (child processes), which in turn can create still other child processes, giving birth to a hierarchy of processes (a tree of processes).
10. A ___________ is a collection of related information, usually stored on a disk or on other external memory (floppy disk, CD, DVD, tape, flash drive, and so on).

You can post only the missing words like this:

1. xxxx
2. yyyy
....
10. zzzz

I would prefer the plain text format for your answers, instead of other formats like DOC, RTF etc. (do not attach files unless necessary)

  • Answer

1. body / soul
2. software
3. convenience
4. efficiency
5. four
6. integrated circuits
7. network
8. process
9. spawn
10. file

Week 2 Discussion - Processes vs Threads

  • Question

Find common features and differences between processes and threads from several points of view (usage, size, execution, life cycle, implementation, etc.)

Then focus (and post here) on one common feature and/or difference that you found.

Do a little research and try to add a few things that are not presented in the online module commentary.

Please avoid repetition of the same list of similarities and differences.

I would suggest to pick one similarity / difference and elaborate a little bit on that subject, perhaps with concrete examples on how things are done on a certain OS or another.

Examples always help understanding the topic.

  • Answer

A process is an executable unit of a program, which includes executable image, cpu information. A thread is processing unit able to run concurrently which is created in a process.

For example, .exe file is a process on Windows. If you run notepad.exe, you can open and edit multiple windows in parallel. They are the same one process, but they each are individual threads.

Homework 2

  • Question

A. Implement Program 2.8 from Module 2 Commentary (and familiarize with C programming on nova in the process)

Create the "w2" directory in you nova home directory (mkdir w2). Save the C source code on nova, in your "w2" directory, in the file "w28.c". Compile the source code with the command:

gcc w28.c -o w28

and thus we obtain the executable "w28". You can execute it with the command:

./w28

Run the program several times and notice the behaviour of the program.

Post the file "w28.c" and the executable "w28" in the Assignment folder (under H2 assignment).

B. Using the information from module 2, (especially the commentary), please fill in the blanks in the following sentences:
[4 points = 0.4 * 10]

1. The only way a process can come into existence is by being created by its __________ process.
2. In UNIX the first process is called the ________ process.
3. The fork() function in the parent returns a _______________, and the fork() function in the child returns _________.
4. The fork() function returns ______ if there is an error and it could not create a child process.
5. The CPU scheduling policy used in UNIX is called _________________.
6. A _________ of execution can be seen as a sort of small or lightweight process.
7. It is in the _________ method that we provide some work (some code statements) for a thread to execute.
8. Like processes, threads can be put to sleep (using the ________ method), and threads can wait for each other (using the _________ method).
9. The operating system component in charge of applying CPU scheduling is called the ___________, or more precisely, the __________________.
10. There are two main types of scheduling policies used today: _______________ scheduling and _______________ scheduling.

  • Answer for Question A
  • w28.c
#include <stdio.h>
#include <unistd.h>
int main()
{
    int pid;
    pid = fork();
    switch(pid)
    {
    case -1: 
        /* an error occurred */
        printf("Fork error"); 
        break;
    case 0:  
        /* this code is executed by the child process */
        printf("I am the child process\n"); 
        printf("My pid is %d\n", getpid());
        printf("My parent's pid is %d\n", getppid());
        printf("I have no child\n");
        break;
    default: 
        /* this code is executed by the parent process */
        printf("I am the parent process\n");
        printf("My pid is %d\n", getpid());
        printf("My parent's pid is %d\n", getppid());
        printf("My child has the pid %d\n", pid);
    }
}
  • Execution Result
nova2> ./w28
I am the parent process
My pid is 21332
My parent's pid is 21262
My child has the pid 21333
I am the child process
My pid is 21333
My parent's pid is 21332
I have no child

I executed the executable "w28" created from "w28.c." I could see the pid of the parent's parent, the parent's pid, and child's pid. After executing several times, pids are incremented randomly except for the pid of the parent's parent. After terminating the SSH connection, then the pid of the parent's parent is updated. In my execution results, the range of pids was between 9000s and 20000s.

  • Answer for Question B

1. parent
2. init
3. zero integer, non-zero integers
4. -1
5. time sharing
6. thread
7. start
8. sleep, wait
9. scheduler, the process scheduler
10. pre-emptive, non-pre-emptive

Week 3 Discussion - Scheduling Algorithms

  • Question

Pick one scheduling algorithm and give us your opinion about it; use different points of view (interactive/batch, slow/fast, easy/difficult to implement/understand, etc.)

The post should reflect your own understanding, use your own words (don't repeat paragraphs from the online material or the textbook).

If you pick an algorithm that was already chosen (and posted) by another colleague, your post should be original (try covering different angles, give some examples, etc.).

OR (optional): Suggest a new scheduling algorithm. Show its advantages and disadvantages.

  • Answer

The round-robin (RR) scheduling algorithm is designed especially for time- sharing systems. It allows the system to switch between processes. Each process gets a small unit of CPU time called time quantum or time slice.

The advantage of this algorithm is not to cause resource starvation because the system doesn't prioritize processes.

Homework 3

  • Question

Write a C program ("procs.c") that creates three processes: a parent process that creates two child processes.

The first child should do the following:

  • display "First child is born, my pid is ..."
  • display 100 times the message "First child executes iteration X", where X is the number of the iteration
  • display "First child dies quietly."

The second child should do the following:

  • display "Second child is born, my pid is ..."
  • display 100 times the message "Second child executes iteration X", where X is the number of the iteration
  • display "Second child dies quietly."

The parent process should do the following:

  • display "Parent process is born, my pid is ..."
  • create the first child
  • create the second child
  • wait for both children to complete their execution
  • display "Parent process dies quietly."

Compile the program on nova using gcc and name the executable "procs.exe". Execute the program several times and notice how the output of the two children interlace. All files (procs.c and procs.exe) should be placed in your nova home directory and also submitted under the H3 assignment.

A possible output of this program is:

nova> ./procs.exe
Parent process is born, my pid is 7847
First child is born, my pid is 7848
First child executes iteration: 1
First child executes iteration: 2
First child executes iteration: 3
First child executes iteration: 4
First child executes iteration: 5
Second child is born, my pid is 7849
Second child executes iteration 1
Second child executes iteration 2
Second child executes iteration 3
First child executes iteration: 6
Second child executes iteration 4
Second child executes iteration 5
Second child executes iteration 6
First child executes iteration: 7
Second child executes iteration 7
Second child executes iteration 8
...
Second child executes iteration 100
Second child dies quietly.
First child executes iteration: 8
...
First child executes iteration: 100
First child dies quietly.
Parent process dies quietly.
  • Answer
  • proc.c
#include <stdio.h>
#include <unistd.h>
#include <stdbool.h>

int main() {
    int i, j, k;
    int state = 0;
    bool isParentSpawned = false;
    for (i = 0; i < 2; i++) {
        if (fork() == 0) {
            /* this code is executed by the child processes */
            if (i == 0) {
                printf ("First child is born, my pid is %d\n", getpid());
                for (j = 1; j <= 100; j++) {
                    printf ("First child executes iteration: %d\n", j);
                }
                printf ("First child dies quietly.\n");
                _exit(0);
            } else if (i == 1) {
                printf ("Second child is born, my pid is %d\n", getpid());
                for (k = 1; k <= 100; k++) {
                    printf ("Second child executes iteration: %d\n", k);
                }
                printf ("Second child dies quietly.\n");
                _exit(0);
            }
            break;
        } else {
            /* this code is executed by the parent process */
            if ( isParentSpawned == false) {
                printf ("Parent process is born, my pid is %d\n", getpid());
                isParentSpawned = true;
            }
            int w_pid;
            w_pid = wait(0);
            if (w_pid > 0) {
                state++;
            }
            if (state == 2) {
                printf ("Parent process dies quietly.\n");
                exit(0);
            }
        }
    }
    return (0);
}
  • Execution Result
nova2> gcc procs.c -o procs.exe
nova2> ./procs.exe
Parent process is born, my pid is 2032
First child is born, my pid is 2033
First child executes iteration: 1
First child executes iteration: 2
First child executes iteration: 3
First child executes iteration: 4
First child executes iteration: 5
First child executes iteration: 6
First child executes iteration: 7
First child executes iteration: 8
First child executes iteration: 9
First child executes iteration: 10
First child executes iteration: 11
First child executes iteration: 12
First child executes iteration: 13
First child executes iteration: 14
First child executes iteration: 15
First child executes iteration: 16
First child executes iteration: 17
First child executes iteration: 18
First child executes iteration: 19
First child executes iteration: 20
First child executes iteration: 21
First child executes iteration: 22
First child executes iteration: 23
First child executes iteration: 24
First child executes iteration: 25
First child executes iteration: 26
First child executes iteration: 27
First child executes iteration: 28
First child executes iteration: 29
First child executes iteration: 30
First child executes iteration: 31
First child executes iteration: 32
First child executes iteration: 33
First child executes iteration: 34
First child executes iteration: 35
First child executes iteration: 36
First child executes iteration: 37
First child executes iteration: 38
First child executes iteration: 39
First child executes iteration: 40
First child executes iteration: 41
First child executes iteration: 42
First child executes iteration: 43
First child executes iteration: 44
First child executes iteration: 45
First child executes iteration: 46
First child executes iteration: 47
First child executes iteration: 48
First child executes iteration: 49
First child executes iteration: 50
First child executes iteration: 51
First child executes iteration: 52
First child executes iteration: 53
First child executes iteration: 54
First child executes iteration: 55
First child executes iteration: 56
First child executes iteration: 57
First child executes iteration: 58
First child executes iteration: 59
First child executes iteration: 60
First child executes iteration: 61
First child executes iteration: 62
First child executes iteration: 63
First child executes iteration: 64
First child executes iteration: 65
First child executes iteration: 66
First child executes iteration: 67
First child executes iteration: 68
First child executes iteration: 69
First child executes iteration: 70
First child executes iteration: 71
First child executes iteration: 72
First child executes iteration: 73
First child executes iteration: 74
First child executes iteration: 75
First child executes iteration: 76
First child executes iteration: 77
First child executes iteration: 78
First child executes iteration: 79
First child executes iteration: 80
First child executes iteration: 81
First child executes iteration: 82
First child executes iteration: 83
First child executes iteration: 84
First child executes iteration: 85
First child executes iteration: 86
First child executes iteration: 87
First child executes iteration: 88
First child executes iteration: 89
First child executes iteration: 90
First child executes iteration: 91
First child executes iteration: 92
First child executes iteration: 93
First child executes iteration: 94
First child executes iteration: 95
First child executes iteration: 96
First child executes iteration: 97
First child executes iteration: 98
First child executes iteration: 99
First child executes iteration: 100
First child dies quietly.
Second child is born, my pid is 2034
Second child executes iteration: 1
Second child executes iteration: 2
Second child executes iteration: 3
Second child executes iteration: 4
Second child executes iteration: 5
Second child executes iteration: 6
Second child executes iteration: 7
Second child executes iteration: 8
Second child executes iteration: 9
Second child executes iteration: 10
Second child executes iteration: 11
Second child executes iteration: 12
Second child executes iteration: 13
Second child executes iteration: 14
Second child executes iteration: 15
Second child executes iteration: 16
Second child executes iteration: 17
Second child executes iteration: 18
Second child executes iteration: 19
Second child executes iteration: 20
Second child executes iteration: 21
Second child executes iteration: 22
Second child executes iteration: 23
Second child executes iteration: 24
Second child executes iteration: 25
Second child executes iteration: 26
Second child executes iteration: 27
Second child executes iteration: 28
Second child executes iteration: 29
Second child executes iteration: 30
Second child executes iteration: 31
Second child executes iteration: 32
Second child executes iteration: 33
Second child executes iteration: 34
Second child executes iteration: 35
Second child executes iteration: 36
Second child executes iteration: 37
Second child executes iteration: 38
Second child executes iteration: 39
Second child executes iteration: 40
Second child executes iteration: 41
Second child executes iteration: 42
Second child executes iteration: 43
Second child executes iteration: 44
Second child executes iteration: 45
Second child executes iteration: 46
Second child executes iteration: 47
Second child executes iteration: 48
Second child executes iteration: 49
Second child executes iteration: 50
Second child executes iteration: 51
Second child executes iteration: 52
Second child executes iteration: 53
Second child executes iteration: 54
Second child executes iteration: 55
Second child executes iteration: 56
Second child executes iteration: 57
Second child executes iteration: 58
Second child executes iteration: 59
Second child executes iteration: 60
Second child executes iteration: 61
Second child executes iteration: 62
Second child executes iteration: 63
Second child executes iteration: 64
Second child executes iteration: 65
Second child executes iteration: 66
Second child executes iteration: 67
Second child executes iteration: 68
Second child executes iteration: 69
Second child executes iteration: 70
Second child executes iteration: 71
Second child executes iteration: 72
Second child executes iteration: 73
Second child executes iteration: 74
Second child executes iteration: 75
Second child executes iteration: 76
Second child executes iteration: 77
Second child executes iteration: 78
Second child executes iteration: 79
Second child executes iteration: 80
Second child executes iteration: 81
Second child executes iteration: 82
Second child executes iteration: 83
Second child executes iteration: 84
Second child executes iteration: 85
Second child executes iteration: 86
Second child executes iteration: 87
Second child executes iteration: 88
Second child executes iteration: 89
Second child executes iteration: 90
Second child executes iteration: 91
Second child executes iteration: 92
Second child executes iteration: 93
Second child executes iteration: 94
Second child executes iteration: 95
Second child executes iteration: 96
Second child executes iteration: 97
Second child executes iteration: 98
Second child executes iteration: 99
Second child executes iteration: 100
Second child dies quietly.
Parent process dies quietly.

Week 4 Discussion - Memory Management

  • Question

Design a memory management scheme for a 64 bit architecture,

using various types of paging and/or segmentation available.

Then highlight its advantages and disadvantages.

Your scheme must be different from your colleagues' schemes.

  • Answer

Week 5 Discussion - File Systems

  • Question

Imagine a new file system structure, describe it (and how it would work), give examples of its advantages and disadvantages.

Shortly describe how you would implement it.

Hint: consider various data structures that you are familiar with and start from there.

Week 6 Discussion - Disk Scheduling

  • Question

Pick one disk scheduling algorithm and give us your opinion about it; use different points of view (interactive/batch, slow/fast, easy/difficult to implement/understand, etc.)

The post should reflect your own understanding, use your own words (don't repeat paragraphs from the online material or the textbook).

If you pick an algorithm that was already chosen (and posted) by another colleague, your post should be original (try covering different angles, give some examples, etc.).

OR (optional): Suggest a new disk scheduling algorithm. Show its advantages and disadvantages.

  • Answer

I think LOOK is the most efficient among disk scheduling algorithms. One of the biggest advantages of this algorithm is that the number of times that the disk head turns for its direction is at most one. Definitely, accessing cylinders sequentially is more efficient than moving backward and forward.

However, the total distance by using LOOK changes a lot depending on whether the head firstly moves backward or forward.

Therefore, I propose a variant of SSTF scheduling algorithm which the disk head firstly moves to an end nearer the current position, and then it moves to the closest cylinder same as SSTF.

Homework 6

  • Question

Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently serving a request at cylinder 108. The queue of pending requests is:

170, 137, 910, 1707, 848, 1309, 432, 1021, 25, 1720, 135.

Starting from the current head position, what is the total distance (in cylinders) that the disk arm moves to satisfy all the pending requests for each of the following algorithms:

1. FCFS
2. SSTF
3. SCAN
4. C-SCAN
5. LOOK
6. C-LOOK

Please provide detailed calculations, not just the final answer.

PS: for some algorithms (SCAN, LOOK) there are two solutions not just one. Please provide both solutions for these algorithms.

  • Answer

Week 7 Discussion - Security

  • Question

1. Encrypt the phrase "My name is _full_name_" using Caesar's cipher described in Module 6 Commentary (use you actual full name instead of "_full_name_", and the English alphabet instead of the Latin alphabet).

2. Shortly describe the security problems that you encountered during your professional activity and how did you solve them.

  • Answer

1. Encrypt the phrase "My name is _full_name_" using Caesar's cipher described in Module 6 Commentary (use you actual full name instead of "_full_name_", and the English alphabet instead of the Latin alphabet).

I encrypted "My name is Yuji Shimojo" by applying K = 8 as below.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z I J K L M N O P Q R S T U V W X Y Z A B C D E F G H

My name was turned into "Ug vium qa Gcrq Apquwrw."

2. Shortly describe the security problems that you encountered during your professional activity and how did you solve them.

Because the number of letters is same as before encryption, the information volume of the original letters can be easily guessed.

Also, the same set of rules is applied to all the letters, so that if the value of K for the original letters is decoded, all the information will be uncovered.

Week 8 Discussion - Lessons Learned

  • Question

What topics in this course did you find the most interesting and possibly applicable to the work you envision in the future? Explain how you would use what you learned?

Should you have a chance to participate in the design and implementation of a new Operating System, what course of action would you follow, what features would you advocate for, what algorithms would you include, etc.?

  • Answer

添付ファイル: fileCMSC412_FinalProject.pdf 1051件 [詳細] fileCMSC412_Homework6.pdf 540件 [詳細] fileCMSC412_hw4solved.pdf 1018件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2015-09-22 (火) 18:08:33 (1151d)