cancel
Showing results for 
Search instead for 
Did you mean: 

RAW devices

admin1979
Super Advisor

RAW devices

Hello,

We are suppose to write a C program wherein,

in the setup of 2 hosts with shared disks array, we have following requirement.

The program should take host number ( 1 or 2 ) , device name as input parameters.

In the first step :

The program should write the current timestamp to the first or second block (2k) of the raw device.
Please note that writes to a raw device need to be aligned to sector borders an need to be in 512 byte chunks in aligned memory.
(The dd command can not be used for testing unfortunately since it "does not currently align its buffers correctly and so cannot be used on raw devices.") (man 8 raw).

In the second step :
create a loop to execute the following every second:
- write a current timestamp
- read and output the current timestamp written by the other node.

Please excuse as I am a newbie.

Any response would be appreciated.


Thanx,
Admin
3 REPLIES
Matti_Kurkela
Honored Contributor

Re: RAW devices

Looks like you're on a cluster programming course, and have received the first introductory exercise.

It seems to me you're expected to already have a basic/intermediate level understanding of programming in general, and the C programming language should be familiar to you.

There does not seem to be anything indicating that you might have solved at least a part of the exercise on your own. You also make the excuse of being a newbie. The overall feel is that you've just chosen a programming course at random, and are just now discovering that you're bitten off way more than you can chew.

If that's the case, you should go to talk with your teacher/lecturer and apologize for choosing a course that is beyond your current level of programming skills. You might ask him/her to recommend a suitable programming course for you: he/she can probably verify your skill level by a few quick questions.

If you've never done any programming in any language, learning the fundamentals is a major effort in itself. As long as your understanding of the basics is incomplete, you will miss important details in the lectures of your current course.

If you have other people do the exercises for you, you will also lose the effect of solving them yourself.

By then, you've lost just about all that makes being on a programming course more effective than just studying alone from a book - so why are you on that course at all?

A good programming course will also include a test or two, where other people cannot help you. If you have other people solving your exercises for you and then go to a test, you're setting yourself up for a failure.

MK
MK
admin1979
Super Advisor

Re: RAW devices

I know the world is full of arrogant people. Now I believe it.
Alzhy
Honored Contributor

Re: RAW devices

admin1979,

Your post does not really portray much what is it you want us to do or enlighten you with.

I have some inkling however so here it goes:

You can simulate the above (I think) using one machine. You can create a "raw file" to simulate you have a raw disk:

dd if=/dev/zero of /somepath/rawdisk bs=1024k count=1024

Then you can simulate writing code to do a dual or multinode r/w access on the same file. Am not 100% sure thiugh if it is good enough simulation of a shared storage.

BUT, if you have a decent enough PC with say 4 GB of Memory, you can have your hown simulated SAN/shared storage environmet cum Laboratory.

- Install LINUX
- Install your favourite virtualization -- vMware, KVM or VBOX/XEN
- Carve up 3 Virtual Sdervers: an OpenFiler NAS, 2 Linux Virtual Servers
- Your OpenFIlerNAS will provide iSCSI storage to your 2 Linux Virtual Servers

Then you can have a truly shaerd storage environment for your cluster adventures...

Cheers!

Hakuna Matata.