프로그램 이중화시 메모리 덤핑 방법에 대하여 고수님들의 조언

air74의 이미지

안녕하세요.

프로세스 이중화시 초기 메모리 덤핑 방법에 대하여 질문 드립니다.

test.h 
struct instance{
   int   instance_id;
   list  *element_list; /* 일반적인 element에 대한 linked list */
}
struct instance  *g_instanc;


test.c
#include "test.h"
int main(void){
   element_t *element_entry;
   g_instance->instance_id = 0
   
   if(stanby){
      초기 덤프 수행
   }
   
   for(i = 0 ; i < MAX_ELEMENT ; i++){
         element_entry = malloc(sizeof(element_t); /* 동적으로 HEAP 에서 메모리 할당 받는다. */
         heapsize = heapsize + sizeof(element_t); /* heap 영역을 standby process 로 덤핑 하기 위하여 */
         put_list(g_instance->element_list, element_entry); /* BSS 영역에 위치하는 g_instance->element_list 에 추가 한다 */
   }

    return TURUE;
}
    

위와 같이 간략한 코드에서 코드도 동일 하며 단지 instance->id 만 다른 stanby process 가 살았을 경우 초기 데이터 dumping 을 위하여 g_instance 의 모든 내용을 standby process 로 덤핑을 하려고 합니다. (실제로 메모리량이 상당히 큽니다. 예제는 단순 하지만 그리고 malloc 을 반드시 사용해야 합니다.)

허나 여기서 문제가 되는 부분이 heap 에서 할당을 받은 메모리와 bss 영역에 위치하는 g_instance 의 포인터와의 매칭 문제 및 malloc 받은 data 의 초기 dumping이 문제 입니다.

고민끝에에 제가 생각한 방법은 다음과 같습니다.

1. g_instance 의 시작 addr 와 사이즈 만큼을 stanby process 에게 전송을 한다. stanby process 에서는 수신한 addr 에서 사이즈 만큼 카피 한다. (bss 영역이므로 address 가 똑같다.)

2. heap 의 시작 addr 에서 heap 사이즈 만큼을 standby process 로 전송을 한다. 마찬가지로 stanby address 에서는 addr 에 사이즈 만큼 카피 한다. (heap 의 시작 address 는 동일하다고 전제)

여기서 질문 드립니다.

1. 위의 2번 작업 수행시 standby process 에서 초기 덤핑이 끝나고 malloc 을 할경우 초기 덤핑시 카피한 사이즈 다음의 heap address 에서 malloc 을 하게 할 수 있을까요? 가능 하다면 방법은 ?

2. 위와 같이 할경우 초기 dumping 후 standby process 에서 g_instance 의 필드 중 malloc 받은 부분을 가리키는 pointer 변수가 가르키는 address 변화가 발생 하진 않는지?

3. malloc 을 반드시 사용 해야 하는 경우 위의 방법말고 더 좋은 방법은 없을까요?

고수님들의 답변 및 조언 바랍니다.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.