Thursday, January 22, 2009

Exercise 3 for engineering

Exercise #3 is published. I've posted a simple server example at the "code examples" post which might be helpfull.

Usefull man pages:
socket()
bind()
listen()
accept()
recv()
send()

recvfrom()
sendto()

ip(7)
tcp(7)

Good Luck!

Tuesday, January 13, 2009

Exercise #2 Clarifications and FAQ

Clrifications
  • Output printing: the shared memory segment should be written to the standard output as a binary string. For e.g.:

int *shm;
...
... = shmget(..., SIZE, ...);
shm = shmat(...);
...
... = write(STDOUT_FILENO, shm, SIZE);

  • Number of semaphores to use: The number of semaphores to use is up to you, but must allow the parallel execution and not serialize it. A single semaphore is not enough and 26^6 is too much. As engineering students you can surely come up with a reasonable number which allows good enough performance. Several possible strategies were discussed in the classroom and you are welcome to define a new one that will work well enough.
  • Characters to count: you should only count lower-case english charachters, i.e. characters 'a'-'z' which are ASCII characters 97-122. All other characters should be ignored, i.e. (extended) ASCII characters 0..96 and 123..255 (e.g. 'A'..'Z', ' ','0'..'9', etc). Each non countable character breaks a sequence, i.e. if any other character than 'a'..'z' appears in a string it will be considered as two different strings. e.g. 'abc abcdeFg', has no countable 6 letters sequence in it and has only a single five characters sequence in it (i.e. 'abcde'), a two 4 charachter sequences ('abcd', 'bcde') etc.
FAQ
Q:
I can't allocate large shared memory segments (more than 26^4*4 needed for the exercise), how can I make larger allocations?

A:
The reason for this is a limit in the kernel by a variable named 'shmmax'. To change the value of shmmax you should execute the following command as root:
# sysctl -w kernel.shmmax=

For the exercise
should be set to 1285089624, which is the sum of:
(26^1+26^2+26^3+26^4+26^5+26^6)*4, or in other words:
# sysctl -w kernel.shmmax=1285089624