Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
02d840a8
Commit
02d840a8
authored
Nov 05, 2010
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Implemented step 1-6 of OS assignment 3.
parent
4b709e57
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
24 deletions
+101
-24
2010-10-19-uva/2010-10-19-uva.tex
2010-10-19-uva/2010-10-19-uva.tex
+5
-5
os/ass3/fishbones.c
os/ass3/fishbones.c
+95
-18
paper/paper.tex
paper/paper.tex
+1
-1
No files found.
2010-10-19-uva/2010-10-19-uva.tex
View file @
02d840a8
...
...
@@ -324,20 +324,20 @@
}
\section
{
Toekomst
}
\frame
{
\frametitle
{
Toekomstbeeld
}
\begin{itemize}
\item
Verschillende vakken
\item
Nakijkmodule
\item
Automatisch nakijken
\item
Verschillende vakken
\item
Nakijkmodule
\item
Automatisch nakijken
\begin{itemize}
\item
Mini unit tests
\item
Fuzzy matching van code
\end{itemize}
\item
Met meerdere gebruikers aan dezelfde code werken
\item
Met meerdere gebruikers aan dezelfde code werken
\end{itemize}
}
...
...
os/ass3/fishbones.c
View file @
02d840a8
...
...
@@ -2,11 +2,14 @@
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
static
void
gup
(
FILE
*
log1
,
FILE
*
log2
,
int
pipe_id
[
2
],
int
myNumber
)
{
FILE
*
log3
;
char
c
;
int
antidote
=
0
;
/* Put any required declarations and initialisations here */
close
(
pipe_id
[
1
]);
...
...
@@ -31,12 +34,53 @@ static void gup(FILE * log1, FILE * log2, int pipe_id[2], int myNumber)
an end-of-file (read returns zero), end your program
with an exit(1) */
if
(
read
(
pipe_id
[
0
],
&
c
,
1
)
<=
0
)
{
fprintf
(
log1
,
"Child %d exited with error
\n
"
,
myNumber
);
fprintf
(
log2
,
"Child %d exited with error
\n
"
,
myNumber
);
fprintf
(
log3
,
"Child %d exited with error
\n
"
,
myNumber
);
fclose
(
log1
);
fclose
(
log2
);
fclose
(
log3
);
exit
(
1
);
}
fprintf
(
log1
,
"Child %d read character '%x'
\n
"
,
myNumber
,
c
);
fprintf
(
log2
,
"Child %d read character '%x'
\n
"
,
myNumber
,
c
);
fprintf
(
log3
,
"Child %d read character '%x'
\n
"
,
myNumber
,
c
);
/* process the character here */
}
while
(
0
);
/* Put a suitable condition here * );*/
switch
(
c
)
{
case
'P'
:
fprintf
(
log1
,
"Child %d eats poison..."
,
myNumber
);
fprintf
(
log2
,
"Child %d eats poison..."
,
myNumber
);
fprintf
(
log3
,
"Child %d eats poison..."
,
myNumber
);
if
(
!
antidote
)
{
fprintf
(
log1
,
"no antidote, child will exit
\n
"
);
fprintf
(
log2
,
"no antidote, child will exit
\n
"
);
fprintf
(
log3
,
"no antidote, child will exit
\n
"
);
break
;
}
else
{
antidote
--
;
fprintf
(
log1
,
"antidote used
\n
"
);
fprintf
(
log2
,
"antidote used
\n
"
);
fprintf
(
log3
,
"antidote used
\n
"
);
}
break
;
case
'A'
:
antidote
++
;
fprintf
(
log1
,
"Child %d finds antidote (now has %d andidote)
\n
"
,
myNumber
,
antidote
);
fprintf
(
log2
,
"Child %d finds antidote (now has %d andidote)
\n
"
,
myNumber
,
antidote
);
fprintf
(
log3
,
"Child %d finds antidote (now has %d andidote)
\n
"
,
myNumber
,
antidote
);
}
}
while
(
c
!=
'\0'
);
fprintf
(
log1
,
"Child %d normal exit
\n
"
,
myNumber
);
fprintf
(
log2
,
"Child %d normal exit
\n
"
,
myNumber
);
...
...
@@ -54,19 +98,25 @@ main(int argc, char * argv[])
{
FILE
*
log1
;
FILE
*
log2
;
char
inString
[
STRING_LENGTH
]
;
int
kiddoCount
=
0
,
pipe_id
[
2
],
i
=
1
;
printf
(
"argc: %d
\n
"
,
argc
);
char
c
;
int
kiddoCount
=
0
,
pipe_id
[
2
]
;
//
, i = 1;
printf
(
"argc: %d
\n
"
,
argc
);
log1
=
fopen
(
"child.log1"
,
"wt+"
);
log2
=
fopen
(
"child.log2"
,
"wt+"
);
setvbuf
(
log2
,
NULL
,
_IONBF
,
BUFSIZ
);
/* So log1 is buffered; log2 is not buffered, which means that output
to log2 is written immediately. */
if
(
pipe
(
pipe_id
)
)
{
fprintf
(
stderr
,
"Error %d occured while createing the pipe
\n
"
,
errno
);
exit
(
1
);
}
/* create the pipe somewhere around here (why?).
remember to test for success!! */
while
(
fgets
(
inString
,
STRING_LENGTH
,
stdin
)
)
while
(
(
c
=
getchar
()
)
)
{
/* You can now choose to use only the first character in the
string (inString[0]), or the entire string (how would you test
...
...
@@ -74,33 +124,60 @@ main(int argc, char * argv[])
Anyway, read a character, echo it to both log files
and write it into the pipe (unless you have to call fork)
*/
if
(
/* suitable condition */
)
/* Ignore newlines and spaces */
if
(
c
==
'\n'
||
(
int
)
c
==
32
)
{
/* write to pipe */
continue
;
}
fprintf
(
log1
,
"Character %x read
\n
"
,
c
);
fprintf
(
log2
,
"Character %x read
\n
"
,
c
);
printf
(
"Character '%c' read
\n
"
,
c
);
if
(
c
==
'q'
)
{
break
;
}
else
if
(
c
==
'P'
)
{
wait
();
}
else
if
(
c
!=
'f'
)
{
if
(
write
(
pipe_id
[
1
],
&
c
,
1
)
!=
1
)
{
perror
(
"Cannot write to pipe
\n
"
);
exit
(
1
);
}
}
else
{
pid_t
child_id
;
kiddoCount
++
;
kiddoCount
++
;
/* When you fork, be sure to print the process id of the child
(if the fork succeeds) and an error message otherwise */
if
(
child_id
=
fork
()
)
{
/* What code should go here ? */
}
else
switch
(
(
child_id
=
fork
())
)
{
/* What goes here ? */
case
-
1
:
perror
(
"Child could not be created
\n
"
);
exit
(
1
);
case
0
:
gup
(
log1
,
log2
,
pipe_id
,
child_id
);
break
;
default:
puts
(
"Parent process continuing..."
);
}
}
}
/* normal end of program */
/* close all open log files */
fprintf
(
log1
,
"Program exited normally
\n
"
);
fprintf
(
log2
,
"Program exited normally
\n
"
);
fclose
(
log1
);
fclose
(
log2
);
return
0
;
}
paper/paper.tex
View file @
02d840a8
\documentclass
[twocolumn]
{
article
}
TT
\documentclass
[twocolumn]
{
article
}
\usepackage
{
url
}
\title
{
Web-based digital examination for specific learning areas
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment