User Profile

Collapse

Profile Sidebar

Collapse
rci
rci
Last Activity: Dec 9 '06, 05:13 PM
Joined: Nov 14 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • rci
    replied to Block Server Study Case
    in C
    At last we found the sollution

    Since the objective will be to sync threads
    to interact with the buffer, the buffer
    needs to be placed in a shared memory place

    Being so the malloc idea is quite a bad one

    A straight forward array is the correct
    choice

    instead of the

    char* buffer = malloc (4096 * sizeof (char))

    we need to use

    ...
    See more | Go to post

    Leave a comment:


  • rci
    replied to Block Server Study Case
    in C
    here is the relevant code to understand the problem:

    Code:
    message struct:
    
    typedef struct block_t{
      int op;
      int blockId;
      char blockContents[BLOCK_SIZE];
    } block_server_packet_t;
    
    server:
    ...
    if(message->op == op_read){
    		  buffer_t_erase(message->blockContents);
    		  strcpy(message->blockContents, *(blocos + (message->blockId)));
    ...
    See more | Go to post

    Leave a comment:


  • rci
    started a topic Block Server Study Case
    in C

    Block Server Study Case

    Hi there

    In order to retrieve info from a specific block
    we pass a buffer to a function

    the header of the function is

    read_block (BlockId, char* buffer)

    however when we access the info in the block
    and we try to copy its info to the buffer it goes
    into Segmentation Fault

    buffer is

    char* buffer = malloc (4096 * sizeof (char))

    ...
    See more | Go to post

  • rci
    started a topic Problem reading from stdin
    in C

    Problem reading from stdin

    Hi.
    I want to read several words from stdin (save them in string) and then process this string.
    The problem is that my code works for the first time but when i finish processing i cannot read a new string from stdin, it enters in an infinite loop, printing Request.

    Code:
    while(1) {
    		printf("\nRequest\n>");
    	
    		if(fgets(string, sizeof(string), stdin)!=NULL) {
    			sscanf(string,"%s",comand);
    ...
    See more | Go to post
No activity results to display
Show More
Working...