Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Low level C programming

Name: Anonymous 2010-09-08 4:27

Hello /prog/. Tomorrow, I have an exam about Operating Systems. I just noticed that apparently (although it has never been subject of the lecture), there is always one task about low level C programming, concerning semaphores, in the exam. I have experience in C++ and Java, but I've never done anything as close to the hardware as is required.

Is there any online book or something similar that can teach me low level C in one day?

Example solution for a task of an exam held in 2003:

int main(argc,argv) {
pid_t pid;
int pipefd[2];
int pipebackfd[2];
int r=-1;
char str[100]="Test";
int i;
pipe(pipefd);
pipe(pipebackfd);
if (fork()!=0) {
if (fork()!=0) {
close(1);
dup (pipefd[1]);
close(pipefd[0]);
get_data();
// wait(NULL);
} else {
close(0);
dup (pipebackfd[0]);
close(pipebackfd[1]);
while(r==-1) {
r=get(str);
}
printf("Layer3:str=%s\n",str);
}
}
else {
close(0);
dup (pipefd[0],0);
close(pipefd[1]);
close(1);
dup (pipebackfd[1]);
close(pipebackfd[0]);
fflush(stdout);
while(r==-1){
r=get(str);
}
addcrc(str);
}
return 0;
}

Name: Anonymous 2010-09-08 4:32

When I had an ``exam about Operating Systems', there was some unindented code on it, not unlike in >>1's post. Since I already had like 70 points out of the maximum 60, I wrote that I refuse to work with malformed code. Good times.

Name: Anonymous 2010-09-08 5:07

>>2
70/60?  your a genuis!

Name: Anonymous 2010-09-08 6:49

This isn't low level, you're using an operating system.

Name: Anonymous 2010-09-08 7:17

I just noticed that apparently (although it has never been subject of the lecture)

Sure thing, buddy. Instead of straight out lying, like this, just come clean and ask us to do your homework / studying for you.

Name: Anonymous 2010-09-08 8:13

>>1
Easy: do your exam as you have to, but don't stop on exams. Constantly learn and get new skills by facing interesting problems. And when you find something interesting try to understand (at least superficially) how it works.

Name: Anonymous 2010-09-08 10:23

>>1
just out of curiosity, has your professor ever mentioned the book K&R to you?

Name: Anonymous 2010-09-08 10:33

You should do the exercises in the C section of this book http://en.wikipedia.org/wiki/The_Unix_Programming_Environment

You should also refer to reference on unix syscalls. And K&R if you're having trouble with C.

Just to be extra nice here's the first book I mentioned http://www.4shared.com/get/4H2mOPav/The_Unix_Programming_Environme.html although obviously physical copies are good.

Name: Anonymous 2010-09-08 11:07

You might also need this: http://www.simson.net/ref/ugh.pdf

Name: Anonymous 2010-09-08 11:44

>>7
>>8

Thanks for the suggestions! I'll do my best and hope I'll pass the exam without being perfectly comfortable with C.

Name: Anonymous 2010-09-08 13:08

Read SICP.

Name: Anonymous 2010-09-08 13:14

>>11

I already have a physical copy of it lying next to my monitor, thanks. That's probably more than you can claim.

Name: Anonymous 2010-09-08 13:20

>>12
That's probably more than you can claim.
lol. But don't worry, based on your green name, I can see you are new.

Name: Anonymous 2010-09-08 13:25

>>12
OKAY YOU FUQIN ANGERED AN EXPERT PROGRAMMER

Name: Anonymous 2010-09-08 13:30

You'd have thought reading SICP would have thought him that code should be readable, and thus it should be indented in languages where code is usually indented.

Name: Anonymous 2010-09-08 13:31

s/thought/taught//

Name: Anonymous 2010-09-08 13:36

progrider@こなた:~ echo "You'd have thought reading SICP would have thought him that code should be readable, and thus it should be indented in languages where code is usually indented." | sed -e 's/thought/taught//'
sed: -e expression #1, char 18: unknown option to `s'


Uh-oh!

Name: Anonymous 2010-09-08 16:06

why are operating system classes so obsessed with c and unix?

Name: Anonymous 2010-09-08 16:26

>>18
Because all OSes are written in C and all OSes are derivatives of Unix.

Name: Anonymous 2010-09-08 16:30

Name: Anonymous 2010-09-08 16:34

It's low-level if you don't indent.

Name: Anonymous 2010-09-08 16:34

>>20
That's not an OS.

Name: Anonymous 2010-09-08 16:34

>>18
Take one, find out.

Name: Anonymous 2010-09-08 16:45

>>19
That is alarmingly close to being true today. Less so 15-20 years ago. Weird.

Name: Anonymous 2010-09-08 17:16

>>12
I have a copy laying next to an alarm clock on my floor. I also have a job.

Name: Anonymous 2010-09-08 17:41

>>25
No one cares that you have a job. That was extraneous information.

Name: Anonymous 2010-09-08 18:06

>>26
Read the post I was replying to, it was pointless dickwaving to begin with. Don't shoot the messenger.

Name: Anonymous 2010-09-08 18:46

EXTR MY ANEOUS

Name: Anonymous 2010-09-08 21:28

>>27
But the dickwaving was a relevant reply!
Not that I condone the dickwaving.

Name: Anonymous 2011-02-04 11:27


Don't change these.
Name: Email:
Entire Thread Thread List