@@ -77,43 +77,25 @@ static control_t test_format(const size_t call_count)
7777
7878static uint32_t thread_counter = 0 ;
7979
80- void file_fn (size_t buffer )
80+ void file_fn (size_t *block_size )
8181{
8282 uint32_t thread_id = core_util_atomic_incr_u32 (&thread_counter, 1 );
8383 char filename[255 ] = { 0 };
84- snprintf (filename, 255 , " mbed-file-test-%d.txt" , thread_id);
85- file_test_write (filename, 0 , story, sizeof (story), buffer);
86- file_test_read (filename, 0 , story, sizeof (story), buffer);
87- }
88- void file_4b_fn ()
89- {
90- return file_fn (4 );
91- }
92- void file_256b_fn ()
93- {
94- return file_fn (256 );
95- }
96- void file_1kb_fn ()
97- {
98- return file_fn (1024 );
99- }
100- void file_2kb_fn ()
101- {
102- return file_fn (2048 );
103- }
104- void file_4kb_fn ()
105- {
106- return file_fn (4096 );
84+ snprintf (filename, 255 , " mbed-file-test-%" PRIu32 " .txt" , thread_id);
85+ file_test_write (filename, 0 , story, sizeof (story), *block_size);
86+ file_test_read (filename, 0 , story, sizeof (story), *block_size);
10787}
10888
10989static control_t file_2_threads (const size_t call_count)
11090{
11191 thread_counter = 0 ;
92+ size_t block_size1 = 4 ;
93+ size_t block_size2 = 256 ;
11294
11395 Thread t1;
11496 Thread t2;
115- t1.start (file_4b_fn );
116- t2.start (file_256b_fn );
97+ t1.start (callback (file_fn, &block_size1) );
98+ t2.start (callback (file_fn, &block_size2) );
11799 t1.join ();
118100 t2.join ();
119101
@@ -123,36 +105,19 @@ static control_t file_2_threads(const size_t call_count)
123105static control_t file_3_threads (const size_t call_count)
124106{
125107 thread_counter = 0 ;
108+ size_t block_size1 = 256 ;
109+ size_t block_size2 = 1024 ;
110+ size_t block_size3 = 4096 ;
126111
127112 Thread t1;
128113 Thread t2;
129114 Thread t3;
130- t1.start (file_256b_fn);
131- t2.start (file_1kb_fn);
132- t3.start (file_4kb_fn);
133- t1.join ();
134- t2.join ();
135- t3.join ();
136-
137- return CaseNext;
138- }
139-
140- static control_t file_4_threads (const size_t call_count)
141- {
142- thread_counter = 0 ;
143-
144- Thread t1;
145- Thread t2;
146- Thread t3;
147- Thread t4;
148- t1.start (file_256b_fn);
149- t2.start (file_256b_fn);
150- t3.start (file_1kb_fn);
151- t4.start (file_2kb_fn);
115+ t1.start (callback (file_fn, &block_size1));
116+ t2.start (callback (file_fn, &block_size2));
117+ t3.start (callback (file_fn, &block_size3));
152118 t1.join ();
153119 t2.join ();
154120 t3.join ();
155- t4.join ();
156121
157122 return CaseNext;
158123}
0 commit comments