nezachem 616 Practically a Posting Shark

Sorry, this is not my example. It comes from another person, that why I am confuse also. I just dont get how can we can split a random string into part like compression and decompression EX:'ABCD' into 'A', 'AB', 'ABC', 'ABCD'

The example suspiciously resembles the LZ compression (at least the prefixes and the encode list make certain sense). Please make sure that that another person supplied you with correct figures. Also it would be helpful to know what alphabet is used in the example (the example is almost correct for an alphabet of just X, Y an Z).

nezachem 616 Practically a Posting Shark

Lines 16-19: you allocate just one byte per each variable. Then you copy some substantial strings there. After that all bets are off. Fix the buffer overflows first, and then see if the problem persists.

Salem commented: Bingo! +19
nezachem 616 Practically a Posting Shark

I just realized that your biggest problem is at line 27:

struct sk_buff *skb

It should be

struct sk_buff **skb

I hope you figured it out by now.

nezachem 616 Practically a Posting Shark

Let me jump in. One immediate problem is that redirections seem to be reversed. On ">" your code prepares for reading, and on "<" for writing.

nezachem 616 Practically a Posting Shark

This looks like undefined behaviour

Undefined indeed.

nezachem 616 Practically a Posting Shark

"grasshopper" also means the student

I have to admit I didn't watch Kung Fu (I am not a kung fu adept either, I am rather into a shotokan). That said, i didn't find anything in this article which would support the claim.

nezachem 616 Practically a Posting Shark

As a grasshoper

Man... grasshopper is a development strategy, not a personal epithet. It means "one jump at a time".

I don't need scorring or anything else just a moveing snake and another moving snake since the aim of the assignment is the multiplayer part.

Forget the snake. Start simple. Create a server, which holds a state variable. Create clients which may query it and alter it. Make sure that altering by one client is correctly reflected on all of them. Try to break it (i mean, try really hard). When you are convinced beyond a reasonable doubt that the server withstands all possible abuses, proceed further (TBD at this moment).
This is a grasshopper.

And I think that requres some additional knoledge of unix architecture and system calls

True.

that I don't know from where to aquite. Thanks

Here's a good place. Just ask you questions.

nezachem 616 Practically a Posting Shark

I thought there was the thing in C++ where constant variables were generally optimized away and treated as #defines.

Fantastic. I mean, wow. Phantastic in fact. I wouldn't believe it unless I compiled and run it myself.
The assembly output does show indeed that constant variable x is replaced by a literal. An immediate question arises, what is its address (or a reference to it). It turns out that an anonymous variable - initialized with an original x value - is created, and its address is taken.
A real question is, does the Standard mandate such behaviour?

nezachem 616 Practically a Posting Shark

Your order of arguments for atan2 is wrong. It should be (y, x), not (x, y).

nezachem 616 Practically a Posting Shark

and also took care about the kfree of allocated modules

Just to make sure: you do kfree_skb(sock_buff) , not just kfree, right?

nezachem 616 Practically a Posting Shark

@nezachem : The skb_copy returns the correct value... I have checked it...

Well you did it. Your code does not.

and as far as kfree_skb of sock buff is concerned ... I m not allocating it any memory by some calls... and hence I don't need to de-allocate the memory it has...

Yes you do. That's what my manpage on skb_copy says:

Returns NULL on failure or the pointer to the buffer on success. The returned buffer has a reference count of 1.

I do not see anything in your code which would decrement the refcount.

nezachem 616 Practically a Posting Shark

O i wish i was, it doesn't work?? No idea why or how just doesn't

By design of the OS. Each process has its own working directory; changing it in the child does not affect the parent. That's why cd is a builtin in all *nix shells.

nezachem 616 Practically a Posting Shark

Code:
I guess there's a few ways of making it faster, mostly with the conversion. Like creating an array of bits to send before actually starting transmission.

I don't think it matters. A conversion and bit extraction times are infinitesimal. The problem is somewhere else.

As a side note, I have only tested this at a low baud rate. Does the EscapeCommFunction use the baud rate or is it not used at all?

That's a question I don't have an answer to. Playing with baud rates would be an interesting experiment.

nezachem 616 Practically a Posting Shark

Microsoft will help.

nezachem 616 Practically a Posting Shark

I believe you are supposed to kfree_skb when you done with it. And at least check the value returned from skb_copy. Same goes for all other resources you allocate.

nezachem 616 Practically a Posting Shark

Snippet of client

// loads shm and creates a new_client_id
        client_entry_t client;
	client.shmid = new_client_id;
	client.pid = 1;

	pthread_mutex_lock(&shm->region_mutex);
	add_to_client(shm, &client);
	pthread_mutex_unlock(&shm->region_mutex);
thread_mutex_lock(&shm->region_mutex);
	//shm->num_entries = 0;
	shm->notify = 1;
	pthread_mutex_unlock(&shm->region_mutex);

       printf("\nClient finds SHMID as %ld", shm->first->shmid );

Can you expand a client snippet? I don't quite understand what client_entry_t client; actually is. Is it local var on some procedure? Is it itself shared? If so, how it is attached to the server address space?

Besides that, I am not sure that you may use pthread methods in this context.

nezachem 616 Practically a Posting Shark

Can you elaborate? The cache is "on chip RAM" - It sounds like you're saying that there is another cache* which stores the interrupt vector. Even if this is true, that doesn't explain how having pointers to lists of handlers saves any memory space. Are the lists of handlers stored in a different location other than the cache you're talking about? As far as the gates go, I'm afraid I don't understand. I thought accessing any location in the RAM took the same amount of time.

*when I say "another" cache I mean one other than the cache that is used to bridge the gap between RAM speed being slower than CPU speed.

Anyway, thank you for your reply.

The primary table is stored in an on-chip RAM. It contains pointers to a second tier, which resides at an off-chip RAM. A fetch of an ISR address therefore takes a bus cycle (two, in fact). This is s l o w.

The difference between the RAM used for the primary table, and the cache, is that the primary table is never purged. Caching it means playing a chance game in regard to interrupt latency.

Technically it is correct to say that this table pages are cached yet locked (forever). In any case, the primary table eats up space which otherwise can serve as a true cache. Note that the said space could've also be used for other purposes, such as longer pipeline, larger register file, more execution units, …

nezachem 616 Practically a Posting Shark

A major pro the huge table is a fast dispatch. To make it actually fast, the table shall be stored in an on-chip RAM. This is very expensive gatewise. This is a major con. To minimize gates some designs go to the extreme of a single interrupt vector with a software dispatch. The drawback is larger latency.

A chained table takes less gates in the processor, but is slower due to an extra RAM access.

There are other design considerations of course. Prioritizing them depends on the target application.

nezachem 616 Practically a Posting Shark

I think now I can tell you more...
I found out that if you right click the blue bar of the border at the top of the program's window, you have propeties and there's history for the lines... I need a code that increases them.

Will SetConsoleScreenBufferSize help?

nezachem 616 Practically a Posting Shark

Just tried that approach, the oscilloscope said it was ~100 Hz.

It is ridiculously low. I'd suspect that the delays are implemented wrong (did you try not to delay at all?) May I see the code?

nezachem 616 Practically a Posting Shark

Not entirely sure what you mean by sampling, but they refer to it in the datasheet, so I guess you're on to it.

Sampling is a HW slang for reading.

No problem using those pins in hardware, but I'm still a bit in the blue about the clock. Just sending altering 0/1's consistently doesn't seem like the right way to do it.

It is exactly what you need to do.
To send:

For each bit to transfer,
    drive DTR to the bit value
    drive RTS high
    timeout for a few usecs
    drive RTS low
    timeout for a few usecs

To receive:

For each bit to transfer,
    drive RTS high
    read DSR
    timeout for a few usecs
    drive RTS low
    timeout for a few usecs

To fiddle with signals, use EscapeCommFunction For the exact timeout value refer to the datasheet.

nezachem 616 Practically a Posting Shark

Why would I want to do that when all I want is to capture the Esc when pressed at the keyboard (and without pressing the Enter key too)?

To make sure that stdio is capable of handling it.

nezachem 616 Practically a Posting Shark

Sorry but hitting the Esc key does nothing

Now create a file with an escape, and run your program with input redirected from it.

There pressing Esc prints ^[

Yes, that's the way an xterm visualizes escape.

nezachem 616 Practically a Posting Shark

AFAIK ESC can not be detected using standard i/o, such as getchar() and fgets(). Same with other special keys such as function and arrow keys.

Not so. From the standard IO perspective, escape is just a regular character. getchar is perfectly happy to read it, and putchar - to print. You can easily verify that with a help of a trivial cat-like program

while((ch = getchar()) != EOF)
        putchar(ch)

feeding it a file with escape in it.

The problem lies outside the stdio. The offending party is either a console driver, or a framework, or whatever else, which intercepts the escape and interprets it (in case of Windows console, it is a console driver).

If the application is desperate to see the escape, it must configure the offensive driver, replace it or bypass it somehow. How to do it is not addressed by a programming language.

nezachem 616 Practically a Posting Shark

OK, got the picture (hopefully). Correct me if I am wrong, you have to drive two lines and sample the third one.
If this is the case, I'd connect RTS to SCK, DTR to MOSI, and DSR to MISO.

nezachem 616 Practically a Posting Shark

Why must stddef.h be in /usr/include?

This is a way the compiler works. A source file does #include <stddef.h> , and the compiler looks it up in /usr/include .

Any more suggestions?

I gather that you do have /usr/include/linux/stddef.h , which means that you have the kernel-devel headers installed. What you are missing (judjing by the absence of /usr/include/stddef.h ) is the libc development package. You need to install it. It is called libc-devel . I am not familiar with Fedora administration and can't tell you the exact command.

PS: You can not just remove these dependencies. A compilation will fail at a different phase with a different message.

nezachem 616 Practically a Posting Shark

'make depend' looks promising.

However, I get a bunch of these:

makedepend

This is really ancient. Please disregard my PPS from the last post.

Is there a more "c++" header to use instead of "unistd.h"? I think cstddef has replaced stddef.h, so maybe this is the problem?

Thanks,
Dave

Yet another crystal ball type guess. Did you install libc6-dev package? stddef.h must be in /usr/include.

nezachem 616 Practically a Posting Shark

There is no 'configure' file. The readme just says to make sure opengl is installed. There are no autoconf sources. The depend target says:

depend:
cd src; make depend-all

O! Did you try to make depend at the command prompt (I'd even do make clean depend if there's a clean target as well)?

PS:

So if I can't regenerate, can I just manually remove those stddef.h kinds of dependencies? It doesn't really make sense to build a header file, does it?

It surely doesn't, and nobody is going to build them. Notice that there is really no rule for doing that. Such a dependency guarantees recompilation in case any of them change (e.g. you upgraded your GCC).

PPS:
I can bet that the make depend boils down to calling gcc with the -M switch. You can make a huge favor to developers by patching it to -MM.

nezachem 616 Practically a Posting Shark

Since there are zillions of such lines, and they refer to a particular gcc installation, the makefile is most likely autogenerated. Check the Readme (or Install) for clues of how to regenerate it. Does the tarball have something like configure? Is there a 'depend' target in the makefile? autoconf sources?

nezachem 616 Practically a Posting Shark

The problem I'm having is it requires a clock signal sent from the PC as synchronisation, and a transmit/receive data line. For these data lines I can just use the WriteFile() and ReadFile() in the win32 API, but so far I havn't found a way of transfering a clock signal.

I was thinking of just sending 0/1's on a serial pin to create a clock. This is likely to be glitchy, and wastes processor power.
Alternatively, I could use the clocksignal in the UART hardware used for the RS232 protocol. However, so far I've been unable to find a way of transmitting this clocksignal over a serialpin.

Can you elaborate, what this signal is supposed to synchronize? What frequencies are required, what accuracy?
AFAIK, the internal UART clock is not connected to any pin. To drive RTS and DTR use EscapeCommFunction.

nezachem 616 Practically a Posting Shark

True -- but do you know why? And if you do, why don't you correct the OP rather than imply my post is of no help.

Didn't mean to imply that.
Speaking of why, of course I do. I wanted OP to figure this "why" out.
To add a hint, the comparison in question compares not values, but statically allocated pointers, which may not possibly be equal.

nezachem 616 Practically a Posting Shark

> what is the value of info.regis?

That really doesn't matter, because the comparison at line 21 is guaranteed to yield true.

nezachem 616 Practically a Posting Shark

>I made this program but I was then told that the function prototype can only have one argument and the program that i made has three arguments

Told by whom?
If it was a professor, than dump him. If it was a compiler, than change a prototype.

>can someone tell me how to make it so it will with only one argument?

I'd rather change the prototype, so it it will take three arguments. BTW, can we see the prototype?

nezachem 616 Practically a Posting Shark

Banned at Google?

nezachem 616 Practically a Posting Shark

The program will just emit a literal encoded by a backslash escape. It is up to the terminal to interpret it.

nezachem 616 Practically a Posting Shark

when i type ls nothin happens,

Of course:

cmd = strtok(NULL, " ");

  			//Check that there is nothing else to extract
	  		if (cmd == NULL)
	  		{
				break;
	 		}

and the execlp doesn't get a chance.

but when i type ls -l i get invalid command type ls --help , which leads me to think something is happening, and the problem lies within the 2nd tokenizing maybe.

Not exactly. I mean, there are problems with tokenization, but an immediate one is due to a '\n' at the end of input.

nezachem 616 Practically a Posting Shark
char *dir;
...
   		getcwd(dir,50);

Thanks for any help

Allocating some memory for dir would help a lot. The fact that it worked fine in some environment is just a pure (bad) luck.

nezachem 616 Practically a Posting Shark

We aren't psychic...

I am, sort of. At least I have a crystal ball. And it tells me about the problems:
- writing to invalid memory
- printing an address as "%d"
- #including conio.h

nezachem 616 Practically a Posting Shark
int * FileFunc::LoadFile(char *fileName)
{
	int *pSignals = 0;
	int Signal[280];//The array which will store the signal files.
        // Irrelevant code skipped
	pSignals = Signal;//points at the first integer in the array.
	return pSignals;
}

Signal is a local array. Once the function completes, it is gone. It is a pure (bad) luck that you ever display anything correctly.

nezachem 616 Practically a Posting Shark

You mean create a for(i=0;i<=fdmax;i++){ loop №2 or if (FD_ISSET(i, &write_fds)){? I think that it should be second if there, 'cause this is the place where we exactly check the descriptors.

for(i = 0; i < fdmax; i++) {
    if(FD_ISSET(i, &read_fds) {
        handle_read(i);
    }
    if(FD_ISSET(i, &write_fds) {
        handle_write(i);
    }
}

The separate writing loop is OK as well. It's a matter of taste, really.

nezachem 616 Practically a Posting Shark

I see two problem with this code.

The first one is that send may also block. You need to send data only to those sockets which select reported as being writable. In other words, prepare and pass a write_fds as well, and analyze it in a similar manner.

The second one is that send is not guaranteed that all requested nbytes will be sent. You need to check how many bytes actually went out, and queue the rest of them for the next round.

nezachem 616 Practically a Posting Shark

What algorithm do i need that will generate every possible combination of a word of a set length from the user ?

Typically it is done by recursion: for each letter in the word use this letter as a head, and build all possible tails applying the same algorithm to the rest of letters. Some attention is required for non-unique letters.

nezachem 616 Practically a Posting Shark

You should not set a non-blocking node.
Select returns when a requested operation will not block. If a socket is in a non-blocking node, select returns immediately. That defeats the very purpose of select.

nezachem 616 Practically a Posting Shark
typedef struct _node node;

typedef struct _node
{
	int is_leaf;
	node child[THRESHOLD_ITEM_SET];
	list<item_set> candidate_set;
} node;

No you can not.
Try to calculate a size of this structure. Seems to be infinite, don't you think so? In a recursive structure definition the recursive reference must be a pointer:

typedef struct _node node;

struct _node {
    int is_leaf;
    node * child[THRESHOLD_ITEM_SET];
    // Omitting the C++ism
};
nezachem 616 Practically a Posting Shark

Not tied to C++. I know it and Java, just learning ruby. Thought it'd be an interesting thing to learn in one of those contexts, but bottom line is I do need to get the files down (too many to do manually) to my HD, so any suggestion you can offer would be greatly appreciated.

Thanks,
- Ron

In that case, use wget. No programming required whatsoever.

nezachem 616 Practically a Posting Shark

is not calculating all the possible combinations

Why do you think it should?
PS: your rgennum wastes a lot of time, and does not generate true randoms. I'd rather have it as

int rgennum(int min, int max)
{
    return min + rand() % (max - min);
}
nezachem 616 Practically a Posting Shark

Check the logic of the while condition. The loop is skipped only when pizza_establishment is nicks, rays and mikes simultaneously.

nezachem 616 Practically a Posting Shark

//help me i dont know what wrong with list function

There's absolutely nothing wrong with it. What's wrong is how it is called. Look at line 36, and ask yourself what is a type of library[count] .

nezachem 616 Practically a Posting Shark

Thanks. I will try to figure it out from there. I just needed a little boost on it cause it was getting frustrating. I did similair to what you did and got 3 also. its a summation of the formula

pow(double(-1),n)*(4/(2*n +1))

so plug 0 then n++ to 15 starting at 4-4/3+4/5-4/7 etc..
and the answer is not 3.. its like 3.2

(4/(2*n +1)) is an integer division, so every term from 4/5 evaluates to 0. Try (4.0/(2*n +1)) .

nezachem 616 Practically a Posting Shark

Your assumption is correct. You need to escape it:

if(char == '\''){}

Also, you need to use code tags.