Mata Kuliah
: Sistem Operasi
Waktu
: 45 Menit
Kode Soal
:E
1. -
Buatlah sebuah folder baru bernama Musik lalu didalam folder tersebut buatlah
folder baru bernama Dangdut
- Di dalam folder Dangdut buatlah sebuah file bernama UAP.txt yang berisi
Dangdut is the Music of My Country
- Pindahkan file UAP.txt dari folder Dangdut ke folder Musik
Kakek
Giman
Jono
Ayah
Bay
Budi
Anak
Aldo
Aldi
#!/bin/bash
echo "Shell yang digunakan adalah $UNAME"
echo "saat ini jam date +%T"
echo "tanggal time "
Hello.c
#include <linux/module.h>
/* Needed by all modules */
#include <linux/kernel.h>
/* Needed for KERN_INFO */
#include <linux/init.h>
/* Needed for the macros */
static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world Mr. Praktikan\n");
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr. Praktikan\n");
}
module_init(hello_start);
module_exit(hello_end);
6. Modifikasi source code hello.c untuk menampilkan contoh operasi perpangkatan saat
di compile ! (source code untuk soal no 6 terlampir)
materi-2.4.c
1 #include <stdio.h>
2 #include <pthread.h>
3 #include <stdlib.h>
4 #include <time.h>
5
6 time_t current_time;
7 int sharevar;
8
9 void *counter(void *param) {
10
int i = 0;
11
while(i < 10){
12
sleep(1);
13
sharevar += 1;
14
i++;
15
}
16
current_time = time(NULL);
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
7.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
pthread_mutex_t count_mutex
pthread_cond_t condition_var
= PTHREAD_MUTEX_INITIALIZER;
= PTHREAD_COND_INITIALIZER;
void *functionCount1();
void *functionCount2();
int count = 0;
#define COUNT_DONE 10
#define COUNT_HALT1 3
#define COUNT_HALT2 6
main()
{
pthread_t thread1, thread2;
pthread_create( &thread1, NULL, &functionCount1, NULL);
pthread_create( &thread2, NULL, &functionCount2, NULL);
pthread_join( thread1, NULL);
pthread_join( thread2, NULL);
printf("Final count: %d\n",count);
exit(EXIT_SUCCESS);
}
// Write numbers 1-3 and 8-10 as permitted by functionCount2()
void *functionCount1()
{
for(;;)
{
// Lock mutex and then wait for signal to relase mutex
pthread_mutex_lock( &count_mutex );
// Wait while functionCount2() operates on count
// mutex unlocked if condition varialbe in functionCount2() signaled.
pthread_cond_wait( &condition_var, &count_mutex );
count++;
pthread_mutex_unlock( &count_mutex );
if(count >= COUNT_DONE) return(NULL);
}
}
// Write numbers 4-7
void *functionCount2()
{
for(;;)
{
pthread_mutex_lock( &count_mutex );
if( count < COUNT_HALT1 || count > COUNT_HALT2 )
{
// Condition of if statement has been met.
// Signal to free waiting thread by freeing the mutex.
// Note: functionCount1() is now permitted to modify "count".
pthread_cond_signal( &condition_var );
}
else
{
count++;
printf("Counter value functionCount2: %d\n",count);
}
pthread_mutex_unlock( &count_mutex );
if(count >= COUNT_DONE) return(NULL);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<stdio.h>
#include<string.h>
main()
{
// n= banyak proses, AT= Arrival Time, WT= Waiting Time, TAT=
TurnAround Time
// b= burst time, TotWT= Total Waiting Time, TotTA= Total TurnAround
time
// name= nama proses, AvWT= Average Waiting Time, AvTA= Average
TurnAround time
int n, AT[100], b[100], i, j, tmp, WT[100], TAT[100], time[100];
int TotWT=0, TotTA=0;
float AvWT, AvTA;
char name[20][20], tmpName[20];
printf("Jumlah Proses\t= "); scanf("%d", &n);
puts("");
// Masukkan data yang diproses
for(i=0; i<n; i++){
fflush(stdin);
printf(Nama Proses\t= "); scanf(%s, &name[i]);
printf("Arrival time\t= "); scanf(%d, &AT[i]);
printf("Burst time\t= "); scanf(%d, &b[i]);
puts("");
}
for(i=0; i<n; i++){
for(j=i+1; j<n; j++)
if(AT[i]>AT[j]){
strcpy(tmpName, name[i]);
strcpy(name[i], name[j]);
strcpy(name[j], tmpName);
tmp=AT[i];
AT[i]=AT[j];
AT[j]=tmp;
tmp=b[i];
b[i]=b[j];
b[j]=tmp;
}
}
time[0]=AT[1];
puts("\n\t Tabel Proses ");
puts("==========================================");
printf("| no | proses\t | time arrival\t | burst |\n");
puts("");
for (i=0; i<=n; i++){
printf("| %2d | %s\t | \t%d\t | %d\t |\n", i+1, name[i], AT[i],
b[i]);
time[i+1]=time[i]+b[i]; //menghitung time pada gant chart
WT[i]=time[i]-AT[i];
TAT[i]=time[i+1]-AT[i];
TotWT+=WT[i];
TotTA+=TAT[i];
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
103
104
105
106
107
108
109
110
111
112
113
114
115
116
}
puts("==========================================");
printf("\tTotal waiting time\t= %d \n", TotWT);
printf("\tTurn around time\t= %d \n", TotTA);
puts("\n\t Tabel Waktu Proses ");
puts("==================================================");
printf("| no | proses\t | waiting time\t | turn arround\t |\n");
puts("");
for(i=0; i<n; i++){
printf("| %2d | %s\t |
TAT[i]);
}
puts("==================================================");
puts("\n");
puts("\t Gant-Chart \n");
for(i=0; i<n; i++){
printf(" %s\t ", name[i]);
}
puts("");
for(i=0; i<n; i++){
printf("|=========");
}
printf("|\n");
for(i=0; i<=n; i++){
printf(" %d\t ", time[i]);
} printf("//diperoleh dari penjumlahan Burst");
puts("\n");
AvWT=(float)TotWT/n;
AvTA=(float)TotTA/n;
printf("\tAverage Waiting Time : %f\n", AvWT);
printf("\tAverage Turn Around TIme : %f\n", AvTA);
}
9. Perhatikan source code nomer 55-62 lalu perbaiki sehingga menjadi seperti contoh
10. Dari pesan error berikut, perbaikilah source code yang ada pada program soal5.c