Home > pthread mutex lock bus > pthread_mutex_lock bus error

Pthread_mutex_lock Bus Error

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Can't figure out Bus Error:10 when reading file up vote 0 down vote favorite I am making a program that reads a text file and puts it into a linked list before carrying on with the other functions. The program also involves a thread function that operates every 5 seconds but the crash is happening at startup. Here is my code for the functions causing problems: #include #include #include #include #include //Strucutres #define NODE struct node struct node { int number; char name[20]; NODE *next; }; #define LIST struct list struct list { NODE *head; NODE *tail; }; #define PARAM struct param struct param { char filename[20]; LIST *listpar; }; pthread_mutex_t mutex; //Declare functions void read_file(LIST **, char *in); LIST * add(LIST **list, char *fake, int fakenumber); void show(LIST **list); void delete(LIST **list); void dispbin(char *input, LIST **list); void *autosaver(void *arg); int main(int argc, char *argv[]) { LIST *list; FILE *in; PARAM *newP; printf("%s",argv[1]); printf("%s",argv[2]); pthread_t thr; pthread_mutex_init(&mutex, NULL); if ((list=(LIST *)malloc(sizeof(LIST)))==NULL) { printf("No memory available"); return 2; } list->head=NULL; list->tail=NULL; if (argc==1) { printf("No files entered"); re

I can tweak? My environment is HP-UX 10.20 with Oracle 7.3.4. The last thing I can trace on the application side before the bus error occurs is a call to an Oracle database logon function named orlon. The same application programs go down with the bus error no matter how many times I run them; others sail right through the Oracle logon without incident no matter how many times. I'm not able to trace the Oracle code or the system calls, partly because I'm not too handy with the HP-UX debugging tools. xdb is a handful and may http://stackoverflow.com/questions/27011607/cant-figure-out-bus-error10-when-reading-file only be partially installed, as near as I can tell. What other tools should I be using to trace this further into Oracle and the kernel? Searching Google groups has turned up reports of similar problems but no resolution that I can use. If there is an Oracle group, I'll post there as well. I'm fresh out of bright ideas on this one and would be grateful for any assistance. http://www.verycomputer.com/38_70d662ec885df2c8_1.htm Top signal 10 bus error at pthread_mutex_lock + 5C by Dennis Hand » Sun, 17 Mar 2002 21:35:53 : because I'm not too handy with the HP-UX debugging tools. xdb is a : handful and may only be partially installed, as near as I can tell. : What other tools should I be using to trace this further into Oracle : and the kernel? Use gdb instead. You can download from: www.hp.com/go/gdb I would be interesting to see what the register values and instructions where it aborted: info reg x /8i $pc-4*4 Top signal 10 bus error at pthread_mutex_lock + 5C by Dierk Groenem » Wed, 20 Mar 2002 03:22:25 > : because I'm not too handy with the HP-UX debugging tools. xdb is a > : handful and may only be partially installed, as near as I can tell. > : What other tools should I be using to trace this further into Oracle > : and the kernel? > Use gdb instead. You can download from: www.hp.com/go/gdb > I would be interesting to see what the register values and instructions > where it aborted: > info reg > x /8i $pc-4*4 Thank you for your ineterest in this

Programming Boards C++ Programming Yet another n00b in pthreads ... Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: http://cboard.cprogramming.com/cplusplus-programming/101027-yet-another-n00b-pthreads.html Yet another n00b in pthreads ... Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 03-28-2008 #1 dimis View Profile View Forum Posts Registered User Join Date Mar 2008 Posts 16 Yet another n00b in pthreads ... Hi, I am new in pthread library and perhaps my question is naive. Anyway, here is the problem I want to solve. I want to create pthread_mutex_lock bus N >= 2 threads and one of them (from now on "generator") will always fill in with "chunks of data" a shared queue, while the rest (N-1) threads will get the data from the queue (assuming there is something) - call these (N-1) "workers". For this purpose I decided to use a mutex for references in queue, as well as a condition variable. Hence, my idea is that, if the workers can't find data in queue, they should pthread_mutex_lock bus error wait for a signal. Obviously the "generator" sends that signal once new data have been added into the queue. So, conceptually, here is how I implemented those functions initially (numbered lines for clarity): Code: 01: generator(){ 02: while (!created_required_amount_of_data) { 03: data <-- create_data () 04: lock (mutex) 05: enqueue (data) 06: if (there_are_threads_waiting) 07: send_condition_signal () // <---- NOT broadcast 08: unlock (mutex) 09: } 10: } I guess the above is fine. Let's switch to the problematic "worker": Code: 01: worker (){ 02: while (!processed_required_amount_of_data) { 03: lock (mutex) 04: if (queue_is_empty()) { 05: waiting_threads++ 06: wait_for_signal () 07: waiting_threads-- 08: } 09: data <-- dequeue_data () 10: unlock (mutex) 11: process (data) 12: } 13: } Unfortunately, the above scenario does NOT work always. It seems to be working *always* if I change line 4 in the "worker" version from an 'if' statement to a 'while' statement. Now, here comes my first question: 1) Is it possible to use signal and wake just a *single one* thread from those waiting for a signal? In the documentation of pthread_cond_signal it is stated that *at least one* thread will wake up. But I only want *exactly* one ... And the above change from 'if' to 'while' saves me almost always on runtime, since one of the threads that wake up check if the queue is empty, and because another one w

 

Related content

No related pages.