UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor gionatha
Visitor
28,512 Views
Registered: ‎03-05-2013

zynq linux mutex sem_init

Jump to solution

Hi!

I use PlanAhead 14.4 with Linux Ubuntu to develop a Linux application for zynq (ZC702 board).

I need to use mutex but I have some errors because semaphore.h file doesn’t have functions declarations.

I see that semaphore.h file used by compiler is a CodeSourcery file.

I suppose I need to use linux files in linux-xlnx directory that I have downloaded to rebuild kernel

Do you think the best way is to change PlanAhead-XPS configuration (I have tried without success)

or create a make file to build project outside XPS tool?

 

 

Has anyone experience in zynq + linux + sem_init function?

 

Thank you very much

Gionatha

0 Kudos
1 Solution

Accepted Solutions
Xilinx Employee
Xilinx Employee
30,219 Views
Registered: ‎03-13-2012

Re: zynq linux mutex sem_init

Jump to solution

You also have to link agains the pthread library. Try adding '-lpthread' to your link command line (and order matters, add it to the end of the command line).

0 Kudos
7 Replies
Scholar milosoftware
Scholar
28,503 Views
Registered: ‎10-26-2012

Re: zynq linux mutex sem_init

Jump to solution

"sem_init" is used in kernel code.

 

If you want to use a mutex in a (user space) application, use the "pthread" library. The man pages or a quick google gives you this:

http://www.xgc.com/manuals/xgclib/x5257.html

 

0 Kudos
Scholar milosoftware
Scholar
28,502 Views
Registered: ‎10-26-2012

Re: zynq linux mutex sem_init

Jump to solution

You can build and test your application on your ubuntu system. All you need to make it work on the Zynq is simply compile it with the ARM cross compiler.

 

If you're serious about building programs for Linux, I'd recommend something like OpenEmbedded to build the whole system, including your application and all the libraries you're going to need. No need to spend five weeks figuring out how to cross-compile and deploy the jpeg library if there's a system that'll do it for you.

0 Kudos
Visitor gionatha
Visitor
28,489 Views
Registered: ‎03-05-2013

Re: zynq linux mutex sem_init

Jump to solution

Thankyou very much for your answers.

I'will try tu use pthread_mutex.

Can I use it with processes created by fork() or only with threads?

In this moment I use fork to create a child process that wait on a socket.

 

I'm exploring zynq+linux possibility, so do you suggest to avoid xilinx-sdk and to use OpenEmbedded...

I have many years of experience about embedded systems but I'm newbie with Linux.

 

Thanks again

gionatha

0 Kudos
Visitor gionatha
Visitor
28,469 Views
Registered: ‎03-05-2013

Re: zynq linux mutex sem_init

Jump to solution

Thank you again for you help

Today I start a new simple program for testing thread and mutex

 

I have tried to complire it with Xilinx-SDK (I will read about OpenEmbedded, but I can't in this moment)

but compiler gives me an error for

pthread_create

and

pthread_cancel

The error is "undefined reference"

 

I have opened pthread.h and I see that functions are defined...

Where I'm wrong?

Thanks

Gionatha

0 Kudos
Xilinx Employee
Xilinx Employee
30,220 Views
Registered: ‎03-13-2012

Re: zynq linux mutex sem_init

Jump to solution

You also have to link agains the pthread library. Try adding '-lpthread' to your link command line (and order matters, add it to the end of the command line).

0 Kudos
Scholar milosoftware
Scholar
28,459 Views
Registered: ‎10-26-2012

Re: zynq linux mutex sem_init

Jump to solution

Sound like your problems aren't related to Zynq at all, it's just lack of Linux knowledge. If you want help with your code, post your code.

 

My advise: Put the board and the Xilinx SDK aside for a while and write and test some programs on your local Linux system. That will save you a lot of time and frustration.

 

Once you have your application running on your PC, then porting it to the Zynq is a no-brainer, it runs the same operating system and the same compiler.

0 Kudos
Visitor gionatha
Visitor
28,455 Views
Registered: ‎03-05-2013

Re: zynq linux mutex sem_init

Jump to solution

solved

I have 15 years of experience about micro and embedded software but only few months about Linux

I used always real-time operating systems.

 

I have added lpthread in project linker libraries and not pthread....

Sorry, and thanks for your helps.

 

I develop on Ubuntu Linux.

What can I use to develop on my PC?

I need a debugger if it's possible

There is someting, as Eclipse, configurated, ready-to-use?

 

Thanks again

Gionatha

0 Kudos