메시지 큐 생성에 관해서

highway7605의 이미지

안녕하세요..

이곳에 첨 글을 올려봅니다.
다름이 아니라 프로세스간 메시지 큐를 사용해서 통신을 하고자 하는데요
몇가지 궁금한 사항이 있어서 메일 드립니다.

리눅스에서는 프로세스당 생성할 수 있는 메시지 큐 수가 제한되어 있는지 궁금합니다.

제가 테스트 해 볼려고 아래와 같은 코드로 테스트 할려고 하니 16개 정도
메시지 큐를 생성하고 난 이후에는 나머지에서는 모두 에러로 떨어지는데
이것이 리눅스 시스템 제한 사항 때문인지 아니면 제가 사용한 아래의 코드가 잘 못 되어서 그런 것인지 조언 부탁 드립니다.

그리고 참고로 프로그램 실행시 에러 코드와 내용은 아래와 같습니다.
ErrorCode : 28, 에러 메시지 : No space left on device

그럼 부탁드립니다.

============================================
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>

#define MAX_TEXT 512

//#define MSG_key (key_t)0xa0089000 /* 0xa0089900 ~ 0xa00899xx */
static int MSG_idx[1001];

struct my_msg_st {
long int my_msg_type;
char some_text[MAX_TEXT];
};

int main()
{
int run = 1;
int msgid;
int i;

char buffer[MAX_TEXT];

struct my_msg_st some_data;
long int msg_to_receive = 0;


printf("Enter some text : ");
fgets(buffer, BUFSIZ, stdin);
strcpy(some_data.some_text, buffer);
if( strncmp(some_data.some_text, "start", 5) == 0 )
{

for( i = 1; i <= 1000; i++ )
{
//msgid = msgget((key_t)MSG_key+(key_t)i, 0666|IPC_CREAT);
msgid = msgget((key_t)i, 0666|IPC_CREAT);
if( msgid == -1 )
{
fprintf(stderr, "msgget failed with error : [%d], [%s]\n", errno, sys_errlist[errno]);
//exit(EXIT_FAILURE);
}
else
{
MSG_idx[i] = msgid;
printf("QNUM - [%d], ID - [%d], [%d]\n", i, msgid, MSG_idx[i]);

sleep(1);
}
}

}

printf("Enter some text : ");
fgets(buffer, BUFSIZ, stdin);
strcpy(some_data.some_text, buffer);
if( strncmp(some_data.some_text, "end", 3) == 0 )
{
for( i = 1; i <= 1000; i++ )
{
if( msgctl(MSG_idx[i], IPC_RMID, 0) == -1 )
{
fprintf(stderr, "msgget failed with error : [%d]\n", errno);
//exit(EXIT_FAILURE);
}
else
{
printf("QNUM - [%d], ID - [%d]\n", i, MSG_idx[i]);

sleep(1);
}
}
}



/*
msgid = msgget((key_t)1234, 0666|IPC_CREAT);
if( msgid == -1 )
{
fprintf(stderr, "msgget failed with error : [%d]\n", errno);
exit(EXIT_FAILURE);
}

while(run)
{
printf("Enter some text : ");
fgets(buffer, BUFSIZ, stdin);
some_data.my_msg_type = 1;
strcpy(some_data.some_text, buffer);

if( msgsnd(msgid, (void *)&some_data, MAX_TEXT, 0) == -1 )
{
fprintf(stderr, "msgsnd failed with error : [%d]\n", errno);
exit(EXIT_FAILURE);
}

printf("Data : [%s}\n", some_data.some_text);
if( strncmp(some_data.some_text, "end", 3) == 0 )
{
run = 0;
}
}
*/

exit(EXIT_SUCCESS);
}
============================================

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.