Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OE
Qt Creator Example Projects
Commits
e1e0d699
Commit
e1e0d699
authored
Sep 25, 2020
by
Brenden Tisler
Browse files
Deleted pthread_hello example in favor of pthread_demo
parent
e7edc2e9
Changes
4
Hide whitespace changes
Inline
Side-by-side
pthread_hello/CMakeLists.txt
deleted
100644 → 0
View file @
e7edc2e9
if
(
EXISTS
"$ENV{HOME}/EMAC-SDK/example-projects/toolchain-selector.cmake"
)
include
(
$ENV{HOME}/EMAC-SDK/example-projects/toolchain-selector.cmake
)
else
()
MESSAGE
(
FATAL_ERROR
"ERROR: Toolchain selection could not be found at $ENV{HOME}/EMAC-SDK/example-projects/toolchain-selector.cmake"
)
endif
()
### General Settings ###
cmake_minimum_required
(
VERSION 2.6
)
project
(
p_hello
)
add_executable
(
p_hello p_hello.c
)
target_link_libraries
(
p_hello pthread
)
######
### Define the remote directory for Qt Creator binary upload ###
file
(
WRITE
"
${
CMAKE_SOURCE_DIR
}
/QtCreatorDeployment.txt"
"
${
REMOTE
}
"
)
######
INSTALL
(
DIRECTORY
${
CMAKE_SOURCE_DIR
}
/pthread_hello DESTINATION share/qt-creator-examples
)
INSTALL
(
TARGETS p_hello RUNTIME DESTINATION bin
)
pthread_hello/CMakeLists.txt.old
deleted
100644 → 0
View file @
e7edc2e9
### Set variables to default values if not defined ###
if(DEFINED ARCH)
else()
SET(ARCH "def")
endif()
if(DEFINED REMOTE)
else()
SET(REMOTE "/tmp\n")
endif()
######
### Parse ARCH variable to get architecture ###
if(${ARCH} STREQUAL "x86")
SET(CMAKE_TOOLCHAIN_FILE ../toolchain.cmake.x86)
elseif(${ARCH} STREQUAL "armv5")
SET(CMAKE_TOOLCHAIN_FILE ../toolchain.cmake.armv5te)
elseif(${ARCH} STREQUAL "armv7")
SET(CMAKE_TOOLCHAIN_FILE ../toolchain.cmake.armv7a)
endif()
######
### General Settings ###
cmake_minimum_required(VERSION 2.6)
project (p_hello)
add_executable(p_hello p_hello.c)
target_link_libraries(p_hello pthread)
######
### Define the remote directory for Qt Creator binary upload ###
file(WRITE "${CMAKE_SOURCE_DIR}/QtCreatorDeployment.txt" "${REMOTE}")
######
pthread_hello/QtCreatorDeployment.txt
deleted
100644 → 0
View file @
e7edc2e9
/tmp
pthread_hello/p_hello.c
deleted
100644 → 0
View file @
e7edc2e9
/**
* @file p_hello.c
*
* Simple pthreads example application.
* Modified from code located here:
* http://www.cs.ucsb.edu/~tyang/class/pthreads/code/p_hello.c
*
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <pthread.h>
#define MAX_THREAD 100
typedef
struct
{
int
id
;
}
parm
;
void
*
hello
(
void
*
arg
)
{
parm
*
p
=
(
parm
*
)
arg
;
printf
(
"Hello from node %d
\n
"
,
p
->
id
);
return
(
NULL
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
n
,
i
;
pthread_t
*
threads
;
pthread_attr_t
pthread_custom_attr
;
parm
*
p
;
if
(
argc
!=
2
)
{
printf
(
"Usage: %s n
\n
where n is no. of threads
\n
"
,
argv
[
0
]);
exit
(
1
);
}
n
=
atoi
(
argv
[
1
]);
if
((
n
<
1
)
||
(
n
>
MAX_THREAD
))
{
printf
(
"The no of thread should between 1 and %d.
\n
"
,
MAX_THREAD
);
exit
(
1
);
}
threads
=
(
pthread_t
*
)
malloc
(
n
*
sizeof
(
*
threads
));
pthread_attr_init
(
&
pthread_custom_attr
);
p
=
(
parm
*
)
malloc
(
sizeof
(
parm
)
*
n
);
/* Start up thread */
for
(
i
=
0
;
i
<
n
;
i
++
)
{
p
[
i
].
id
=
i
;
pthread_create
(
&
threads
[
i
],
&
pthread_custom_attr
,
hello
,
(
void
*
)(
p
+
i
));
}
/* Synchronize the completion of each thread. */
for
(
i
=
0
;
i
<
n
;
i
++
)
{
pthread_join
(
threads
[
i
],
NULL
);
}
free
(
p
);
exit
(
0
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment