Changeset 80 in libcf
- Timestamp:
- 04/30/13 17:12:40 (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf_error.h
r73 r80 53 53 #define CF_ERROR_THREAD CF_ERROR_BASE * 4 54 54 /*------------------------------------------------------------*/ 55 #define CF_ERROR_THREAD_CREATE CF_ERROR_THREAD - 1 56 #define CF_ERROR_THREAD_INVALID_ARGS CF_ERROR_THREAD - 2 55 #define CF_ERROR_THREAD_ALLOC CF_ERROR_THREAD - 1 56 #define CF_ERROR_THREAD_CREATE CF_ERROR_THREAD - 2 57 #define CF_ERROR_THREAD_INVALID_ARGS CF_ERROR_THREAD - 3 58 #define CF_ERROR_THREAD_INIT_ATTR CF_ERROR_THREAD - 4 59 #define CF_ERROR_THREAD_SET_INHERIT_SCHED CF_ERROR_THREAD - 5 60 #define CF_ERROR_THREAD_SET_SCHED_POLICY CF_ERROR_THREAD - 6 61 #define CF_ERROR_THREAD_SET_SCHED_PARAM CF_ERROR_THREAD - 7 57 62 /* }}} thread */ 58 63 -
trunk/src/cf_debug.c
r71 r80 376 376 } 377 377 378 return CF_OK;378 return result; 379 379 } 380 380 … … 392 392 393 393 if (gDebugSingleCtx == NULL) 394 {395 394 result = CF_Debug_CreateCtx (&gDebugSingleCtx); 396 if (result != CF_OK) 397 return result; 398 } 399 400 return CF_OK; 395 396 return result; 401 397 } 402 398 -
trunk/src/cf_thread.c
r79 r80 54 54 * @param callback 스레드 워커 함수 이름 55 55 * @param arg 스레드 함수로 전달할 인자 56 * 57 * @remarks 58 * pthread(POSIX Thread)에서 지원되는 스케줄링 정책은 SCHED_OTHER, SCHED_FIFO, SCHED_RR 등이 존재 <br /> 59 * 일반적으로 설정되는 스케줄링 정책의 기본값은 SCHED_OTHER이며, 솔라리스 환경에서 SCHED_OTHER는 TS(timesharing) 방식으로 명시되어 있음 <br /> 60 * 그러나 개발 단계에서 테스트된 동작은 SCHED_FIFO와 동일하였으며, 때문에 솔라리스 환경에서는 스케줄링 정책을 SCHED_RR로 명시하도록 함 <br /> 61 * <br /> 62 * 참고 url <br /> 63 * - http://kldp.org/node/18841 , "SCHED_OTHER, SCHED_FIFO, SCHED_RR에 대해..." <br /> 64 * - http://blog.naver.com/popjunior/80021646476 , "AIX, CPU 모니터링과 튜닝" <br /> 56 65 */ 57 66 int … … 64 73 THREAD_WORKER f = (THREAD_WORKER) callback; 65 74 66 #if defined(_WIN32) || defined(_WIN64) 67 68 *threadID = (THREAD_TYPE) CreateThread (NULL, 0, f, arg, 0, NULL); 69 if (*threadID == NULL) 70 return CF_ERROR_THREAD_CREATE; 71 #else 72 *threadID = (THREAD_TYPE *) calloc (sizeof (THREAD_TYPE), 1); 73 if (*threadID == NULL) 74 return CF_ERROR_THREAD_CREATE; 75 76 result = pthread_create ((THREAD_TYPE *) *threadID, NULL, f, arg); 77 if (result < 0) 78 return CF_ERROR_THREAD_CREATE; 79 #endif 80 81 return CF_OK; 75 TRY 76 { 77 #if defined(_WIN32) || defined(_WIN64) 78 79 *threadID = (THREAD_TYPE) CreateThread (NULL, 0, f, arg, 0, NULL); 80 if (*threadID == NULL) 81 { 82 result = CF_ERROR_THREAD_CREATE; 83 TRY_BREAK; 84 } 85 #else 86 # if defined(_SOLARIS) 87 pthread_attr_t attr; 88 struct sched_param sched; 89 90 result = pthread_attr_init (&attr); 91 if (result) 92 { 93 result = CF_ERROR_THREAD_INIT_ATTR; 94 TRY_BREAK; 95 } 96 97 result = pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED); 98 if (result) 99 { 100 result = CF_ERROR_THREAD_SET_INHERIT_SCHED; 101 TRY_BREAK; 102 } 103 104 result = pthread_attr_setschedpolicy (&attr, SCHED_RR); 105 if (result) 106 { 107 result = CF_ERROR_THREAD_SET_SCHED_POLICY; 108 TRY_BREAK; 109 } 110 111 sched.sched_priority = 1; 112 result = pthread_attr_setschedparam (&attr, &sched); 113 if (result) 114 { 115 result = CF_ERROR_THREAD_SET_SCHED_PARAM; 116 TRY_BREAK; 117 } 118 # endif // # if defined(_SOLARIS) 119 120 *threadID = (THREAD_TYPE *) calloc (sizeof (THREAD_TYPE), 1); 121 if (*threadID == NULL) 122 { 123 result = CF_ERROR_THREAD_ALLOC; 124 TRY_BREAK; 125 } 126 127 result = pthread_create ((THREAD_TYPE *) *threadID, &attr, f, arg); 128 if (result < 0) 129 { 130 result = CF_ERROR_THREAD_CREATE; 131 TRY_BREAK; 132 } 133 #endif 134 } 135 CATCH_IF (result < 0) 136 { 137 if (result == CF_ERROR_THREAD_ALLOC || 138 result == CF_ERROR_THREAD_CREATE) 139 CF_Thread_Release (threadID); 140 } 141 142 return result; 82 143 } 83 144
Note:
See TracChangeset
for help on using the changeset viewer.